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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:48:04  来源:igfitidea点击:

Git: How to commit a manually deleted file?

gitgithub

提问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.vimis deleted from the plugin folder in my remote repo. I know that I have to use git add && git commitbut I have no file to commit/add because /plugin/dwm.vimis already deleted.

现在,我应该如何提交以便dwm.vim从远程仓库的插件文件夹中删除它。我知道我必须使用,git add && git commit但我没有要提交/添加的文件,因为/plugin/dwm.vim已删除。

回答by s.m.

The answer's here, I think.

答案就在这里,我想。

It's better if you do git rm <fileName>, though.

不过,如果你这样做会更好git rm <fileName>

回答by xdazz

Use git add -A, this will include the deleted files.

使用git add -A,这将包括已删除的文件。

Note: use git rmfor 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>