7

I have been typing git add . for years before commiting changes. From what I understand (from the message below) the modern equivalent would be git add --ignore-removal <pathspec> which is slightly more verbose. Is there a way to revert to the old behavior in the upcoming version 2.0 of git or at least silence this message in the current version?

$ git add .
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like 'log/sunspot-solr-development.log.lck' that are
removed from your working tree are ignored with this version of Git.

* 'git add --ignore-removal <pathspec>', which is the current default,
  ignores paths you removed from your working tree.

* 'git add --all <pathspec>' will let you also record the removals.

Run 'git status' to check the paths you removed from your working tree.
4

1 回答 1

5

您看到的警告来自提交 ccc663b,它改进了提交 45c45e3

第二次提交确实提到:

git add:开始准备“ git add <pathspec>...”默认为“ -A

计划最终使“git add”假装-A在命令行上有路径规范时给出“”

为了使这种转换起作用,人们需要学会说“ git add --no-all subdir/”当他们想要忽略像“”这样的删除路径时subdir/z说“”,或者git add -A subdir/当他们想要获取整个目录的状态时说“”。

" git add" 没有任何参数将继续是无操作的。

所以现代的等价物git add .实际上是git add -A .:请参阅“如何制作 Git”<code>add --all” 默认情况下? ”。

梅尔特米 评论

我什至不确定那是什么意思?有谁知道他们为什么做出这个改变?

我上面提到的提交说明了这个--ignore-removal选项:

当 " git add subdir/" 在没有 " -u" 或 " -A" 选项的情况下运行时,例如

$ edit subdir/x
$ create subdir/y
$ rm subdir/z
$ git add subdir/

该命令不会注意到subdir/z从工作树中删除路径(例如)
这有时会使新人感到困惑,因为可以说“ git add”被告知记录“ subdir/”的当前状态作为一个整体,而不是与该路径规范匹配的工作树中存在的路径的当前状态(后者根据定义排除了" subdir/z" 因为它在工作树中不存在)。

于 2013-10-17T06:12:20.603 回答