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

问题描述

有什么区别:

  • git add .
  • git commit -a

我应该两者都做,还是多余?

Should I be doing both, or is that redundant?

推荐答案

git commit -agit add -u && 的意思几乎[*] 一样git commit.

它与 git add . 不同,因为这会添加未被忽略的未跟踪文件,git add -u 仅将更改(包括删除)暂存为已经跟踪的文件.

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 -u 对当前目录及以下目录的文件进行阶段性更新,相当于 git add -u .git commit -a 阶段并提交对所有跟踪文件的更改.

[*] 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 添加.vs git commit -a的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 11:47