18

我刚刚遇到了这条消息:

$ 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 'README.md' 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.

我认为设置--all是一个非常合理的默认设置,因为reset如果意外添加了某些内容,我可以这样做。如何使该行为默认?

4

2 回答 2

11

您看到的警告来自提交 ccc663b,它本身正在修改提交 45c45e3

第二次提交确实包括:

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

计划最终使“git add”假装-A在命令行上有路径规范时给出“”
解决冲突以删除路径时,当前代码告诉您“ git rm $path”,但是通过这样的更改,您将能够说“git add $path”(当然您可以执行“git add -A $path”今天)。

所以使用 Git 2.0,git add .会做你想做的事,但现在,一个 git 别名是默认获取这个的方式。

git config alias.a 'add -A .'

[alias] 
  a = add -A .

现在(2014 年 3 月)已为下一个版本注册,提交 160c4b1提交 fdc97ab,用于下一个 Git 2.0(2014 年第二季度)。

于 2013-10-17T06:05:24.980 回答
3

使用 git 你可以创建别名,所以你可以试试这个:

git config --global alias.adall 'add . --all'

这里使用“adall”而不是“add”以避免一些不必要的添加,但如果你喜欢添加也可以。

完成此配置后,您可以通过如下命令添加所有内容:

git adall
于 2013-10-17T06:12:26.807 回答