我还是比较新的Git,所以也许我做的事情很愚蠢,但我有一个奇怪的问题......
我为stage
定义了add --all
别名,因为我发现它更短,更不言自明:
D:\MyProject [master +0 ~1 -1]> git config alias.stage "add --all"
D:\MyProject [master +0 ~1 -1]> git config alias.stage
add --all
但是当我运行git stage .
时,它的行为就好像省略了--all
选项一样:
D:\MyProject [master +0 ~1 -1]> git stage .
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 'MyProject.Tests/AssertExtensions.cs' 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.
D:\MyProject [master +0 ~1 -0 | +0 ~0 -1]>
但是,运行git add --all .
会得到预期的结果。
可能导致此问题的原因,我该如何解决?
(我在Windows上使用msysgit和posh-git)
更新:如果我将别名重命名为stg
,它工作正常!!我刚刚意识到 已经是stage
command in Git,它是add
的同义词...所以我无法覆盖它。
答案 0 :(得分:3)
Git已经有了一个内置的stage
命令,它是add
的同义词......显然,用别名覆盖内置命令是不可能的。如果我将别名重命名为stg
,则可以正常使用。