git add。 vs git commit -a [英] git add . vs git commit -a

查看:158
本文介绍了git add。 vs git commit -a的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么区别:


  • git add。

  • git commit -a



或者是多余的?

意味着几乎与 git add -u&& amp;& git commit



它与 git add。不一样,因为它会添加未被忽略的文件不会被忽略, git add -u 只对已跟踪的文件进行更改(包括删除)。



[*]如果您不在存储库的根目录下,则会有细微差别。 git add -u 更新当前目录及其下的文件,它相当于 git add -u。 git commit -a 阶段并将更改提交到所有跟踪文件。


What's the difference between:

  • git add .
  • git commit -a

Should I be doing both, or is that redundant?

解决方案

git commit -a means almost[*] the same thing as 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.

[*] 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 all tracked files.

这篇关于git add。 vs git commit -a的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆