如何使Git“添加 - 所有”默认? [英] How to make Git "add --all" by default?
问题描述
$ git add。
警告:您运行的'git add'既没有'-A(--all)'也没有'--ignore-removal',
,它们的行为将在Git 2.0中相对于您删除的路径发生变化。
这个版本的Git会忽略从工作树中删除
之类的'README.md'之类的路径。
*'git add --ignore-removal< pathspec>',这是当前的默认值,
会忽略您从工作树中删除的路径。
*'git add --all< pathspec>'会让您记录删除。
运行'git status'来检查您从工作树中移除的路径。
我认为设置 - 所有
是一个相当理智的默认,因为我可以重置
如果意外添加了一些东西。我怎样才能使这种行为默认?
您看到的警告来自提交ccc663b ,本身重新制作提交45c45e3 。
第二次提交包括:
git add
:开始准备 git add< pathspec> ...
默认为 -A
h2>
计划最终让git add假装为
-A
是在命令行中存在pathspec时给出的。
当解决冲突以删除路径时,当前代码告诉您git rm $ path
,但有了这样的改变,你可以说git add $ path(当然你可以在今天做git add -A $ path)。
所以在Git 2.0中, git add。
但现在,默认情况下,使用git alias是获得此方法的方式。
git config alias.a'add -A。 '
[别名]
a = add -A。
现在(2014年3月)下一个版本,其中包含提交160c4b1 和提交fdc97ab ,为下一个Git 2.0(Q2 2014)。
I just ran into this message:
$ 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.
I think setting --all
is a pretty sane default, since I can reset
if something was added unexpectedly. How can I make that behavior default?
The warning you see comes from commit ccc663b, itself reworking commit 45c45e3.
That second commit does include:
git add
: start preparing for "git add <pathspec>...
" to default to "-A
"
Plan to eventually make "git add" pretend as if "
-A
" is given when there is a pathspec on the command line.
When resolving a conflict to remove a path, the current code tells you to "git rm $path
", but with such a change, you will be able to say "git add $path" (of course you can do "git add -A $path" today).
So with Git 2.0, git add .
will do what you want, but right now, a git alias is the way to get this by default.
git config alias.a 'add -A .'
[alias]
a = add -A .
This is now (March 2014) registered for the next release, with commit 160c4b1 and commit fdc97ab, for the next Git 2.0 (Q2 2014).
这篇关于如何使Git“添加 - 所有”默认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!