没有 -a 选项的 git commit 有什么影响?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2807899/
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
What is the effect of git commit without the -a option?
提问by ben
What is the difference between these two commands?
这两个命令有什么区别?
git commit -m "added a new page"
and
和
git commit -a -m "added a new page"
I know that the -a option will stage files that have been modified and deleted, but then what does running it without the -a mean?
我知道 -a 选项将暂存已修改和删除的文件,但是没有 -a 的情况下运行它意味着什么?
回答by John Weldon
You have to explicitly stage changes for commitment by using git add
or git rm
.
您必须使用git add
或明确地为承诺进行更改git rm
。
If you use the -a
flag when doing a commit, git will automatically stage any modified and removed files without you having to explicitly stage them using add
or rm
, etc.
如果您在-a
提交时使用该标志,git 将自动暂存任何修改和删除的文件,而无需您使用add
或rm
等明确暂存它们。
If you don'tspecify -a
, any files that have been modified or removed, but not explicitly staged using git add
or git rm
will be ignored in the commit.
如果未指定-a
,则任何已修改或删除但未使用git add
或显式暂存的文件git rm
将在提交中被忽略。
update
更新
As Dr. Gianluigi Zane Zanettini says - -a
does not add newfiles to the index, so if you have completely new files you shouldn't expect -a
to ad them.
正如 Gianluigi Zane Zanetini 博士所说 --a
不会将新文件添加到索引中,因此如果您有全新的文件,则不应期望-a
添加它们。
http://www.kernel.org/pub/software/scm/git/docs/git-commit.html
http://www.kernel.org/pub/software/scm/git/docs/git-commit.html