git 添加。vs git commit -a
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3541647/
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 add . vs git commit -a
提问by Yarin
What's the difference between:
有什么区别:
git add .
git commit -a
git add .
git commit -a
Should I be doing both, or is that redundant?
我应该两者都做,还是多余的?
回答by CB Bailey
git commit -a
means almost[*] the same thing as git add -u && git commit
.
git commit -a
几乎 [*] 与git add -u && git commit
.
It's not the same as git add .
as this would add untracked files that aren't being ignored, git add -u
only stages changes (including deletions) to already tracked files.
这与git add .
添加未被忽略的未跟踪文件不同,git add -u
仅对已跟踪文件进行阶段更改(包括删除)。
[*] There's a subtle difference if you're not at the root directory of your repository. git add -u
stages updates to files in the current directory and below, it's equivalent to git add -u .
whereas git commit -a
stages and commits changes to alltracked files.
[*] 如果您不在存储库的根目录中,则存在细微差别。git add -u
阶段更新的文件在当前目录及以下,这相当于git add -u .
而git commit -a
阶段,并提交更改所有跟踪文件。
回答by alternative
回答by Dilip
By using the git commit -a switch with the commit command to automatically "add" changes from all known files (i.e. all files that are already listed in the index)
通过使用带有 commit 命令的 git commit -a 开关来自动“添加”所有已知文件(即已在索引中列出的所有文件)的更改