git 添加 .与 git commit -a 比较
之间有什么区别:
git add .
git commit -a
我应该两者都做,还是多余的?
What's the difference between:
git add .
git commit -a
Should I be doing both, or is that redundant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
git commit -a
的意思几乎[*]与git add -u && 相同。 git 提交
。它与 git add . 不同,因为这会添加不会被忽略的未跟踪文件,
git add -u
仅对已跟踪的文件进行阶段性更改(包括删除) 。[*] 如果您不在存储库的根目录中,则会有细微的差别。
git add -u
阶段更新当前目录及以下目录中的文件,它相当于git add -u .
而git commit -a
阶段并对所有跟踪文件提交更改。git commit -a
means almost[*] the same thing asgit 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.[*] 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 togit add -u .
whereasgit commit -a
stages and commits changes to all tracked files.git commit -a
自动在它知道的所有文件上调用git add
。您可以使用 git add 来选择要提交的文件。有关更多信息,请参阅文档:此处git commit -a
automatically invokesgit add
on all files it knows about. You can usegit add
to select what files to commit. Consult the docs for more info: here通过使用 git commit -a 开关和 commit 命令自动“添加”所有已知文件(即索引中已列出的所有文件)的更改
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)