Git:如何提交手动删除的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12987907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git: How to commit a manually deleted file?
提问by ronnie
In my git repository I manually deleted a file(rm
) after moving it to another folder. I than committed all the changes to my repo but now when I do git status .
在我的 git 存储库中,我将一个文件 ( rm
) 移动到另一个文件夹后手动删除了它。我将所有更改都提交给了我的回购,但现在当我这样做时git status .
ronnie@ronnie:/home/github/Vimfiles/Vim$ git status .
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: plugin/dwm.vim
#
no changes added to commit (use "git add" and/or "git commit -a")
Now, how should I commit so that dwm.vim
is deleted from the plugin folder in my remote repo. I know that I have to use git add && git commit
but I have no file to commit/add because /plugin/dwm.vim
is already deleted.
现在,我应该如何提交以便dwm.vim
从远程仓库的插件文件夹中删除它。我知道我必须使用,git add && git commit
但我没有要提交/添加的文件,因为/plugin/dwm.vim
已删除。
回答by s.m.
回答by xdazz
Use git add -A
, this will include the deleted files.
使用git add -A
,这将包括已删除的文件。
Note: use git rm
for certain files.
注意:git rm
用于某些文件。
回答by Kache
It says right there in the output of git status
:
它在输出中说git status
:
# (use "git add/rm <file>..." to update what will be committed)
so just do:
所以就这样做:
git rm <filename>