我对git还比较陌生,只是提交了一些额外的文件,还添加了一些会导致文件错误的内容。
我想删除额外的文件以及推送编辑的文件。我该怎么做?
一个投稿人让我用武力
发布于 2016-11-12 07:17:52
步骤1:
从磁盘中删除不需要的文件。通过修复您需要修复的内容来编辑文件。
步骤2:
执行以下命令:
git add *
git commit -m "some message"
git push origin master如果您正在其他分支工作,只需更改您的分支的名称主人。
发布于 2016-11-12 07:10:59
很简单。
通过编辑和添加新内容,按照您希望的方式更改文件系统。
一旦内容准备就绪,将其添加到阶段并提交。
简写版:
// If you only wish to remove files from the repository
git rm --cached <file to remove>
// or if you only wish to remove files form disk & repo
git rm <file to remove>详细版本:
.. Current commited content
.. edit any file or remove any file
// Add the changes to the stage area.
// Any new change here will be added to the latest commit later on
// with the commit --amend flag
git add <files to be changed>
// if you wish to remove the extra files - remove them from stage
// and commit the change
git rm --cached <file to remove>
// Update the latest commit and add the new changes made to the index
git commit --ammend
// Update remote server with the new changes
git push -f origin <branch>发布于 2016-11-12 08:51:40
要从工作目录和工作树中删除不需要的文件:
git rm <file1> <file2>...
git add . && git commit --amend --no-edit--amend选项修改HEAD指向的提交,而不是创建新的提交,而--no-edit选项允许您修改提交而不更改提交消息。
若要删除目录,请使用递归选项-r,并随后列出要删除的目录名。您可能希望将其与--dry-run选项(速记:-n)一起使用,以查看哪些文件将被删除。
https://stackoverflow.com/questions/40560469
复制相似问题