这两个命令的命令行工作
git symbolic-ref HEAD | sed -e "s#^refs/heads/##"
和
git branch | grep \* | cut -d ' ' -f2
当加入[别名]下gitconfig
thisbranch = !git symbolic-ref HEAD | sed -e "s#^refs/heads/##"
thisbranch2 = !git branch | grep \* | cut -d ' ' -f2
我得到fatal: bad config line 16 in file /Users/<me>/.gitconfig
这是第二行。 我最初的问题是获取当前分支成一个别名感谢这个答案 。 所以我主要是好奇,为什么在命令行上都工作,但只有1个可以配置工作。 我猜测它的' '
需要转义,但是这只是一个猜测。