Git别名 - 多个shell命令在最后一个命令上失败

时间:2015-08-20 14:34:02

标签: git macos shell

我有这个git别名:

MSB3073: C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v14.0\Microsoft.CodeContracts.targets(642,5): The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccdocgen.exe" "@obj\Release\QuickGraphccdocgen.rsp"" exited with code -1073741571.

最后的命令每次都失败,如果有的话 - 例如:git status,exit 1等。每次我得到“xyz:command not found”作为最后一个命令。

我在OSX上运行它。 控制台输出是:

[alias]
# rebase feature branch onto current branch (typically release branch)
rebm = !sh -c 'echo rebasing branch \"$0\" on top of \"$1\" && git checkout \"$0\" && git pull origin \"$0\" && git rebase \"$1\" && git checkout \"$1\" && git merge \"$0\" && echo all done && exit 1'

1 个答案:

答案 0 :(得分:3)

Adam给我发了这个.gitconfig文件,所以我找到了原因 - 这是由他的别名中的不可打印字符引起的:

$ cat -v -e -t .gitconfig
rebm = !sh -c 'echo rebasing branch \"$0\" on top of \"$1\" && git checkout \"$0\" && git pull origin \"$0\" && git rebase \"$1\" && git checkout \"$1\" && git merge \"$0\" && echo all done &&M-BM- exit 1'$

所以您现在可以清楚地看到问题的最后一行:&&M-BM- exit 1

有关此类人物的更多信息:
https://en.wikipedia.org/wiki/Control_character
https://en.wikipedia.org/wiki/Unicode_control_characters