如何提交只修改(而不是新的或删除)的文件? [英] How to commit only modified (and not new or deleted) files?
问题描述
git status
显示了一堆被修改过的文件和一些被删除的文件。我想先提交已修改的文件,然后删除已删除的文件。我在 git add
>中看不到任何选项,这使我可以执行此操作。我怎么做到的?
git status
shows a bunch of files which were modified and some which were deleted. I want to first commit the modified files and then the deleted ones. I don't see any option in git add
that enables me to do this. How can I do it?
编辑:正如指出的那样, git add
wouldn不管怎么说,已经删除了已删除的文件,所以 git add。
可以。但它有包含未跟踪的文件的副作用,这也是我想避免的。我相应地改变了问题的标题。
EDIT: As pointed out, git add
wouldn't have staged the deleted files anyway, so git add .
would do. But it has the side-effect of including files which weren't tracked, which I would also like to avoid. I have changed the title of the question accordingly.
推荐答案
以下命令应该做到这一点: b
The following command should do the trick:
git commit -a
或
git commit -am "commit message"
从 Pro Git 书籍:
From the Pro Git book:
为git commit命令提供-a选项可以让Git自动对每个已经在提交之前进行跟踪的文件进行分段处理
Providing the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit
这篇关于如何提交只修改(而不是新的或删除)的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!