8

我正在尝试向我的 gitconfig 文件添加一个别名命令,它在我添加的行上报告“错误的配置文件”。我怀疑这与sed命令和一些转义问题有关,但我不知道它应该是什么。这是命令,添加了换行符以提高可读性:

impact = !git ls-files -z
       | xargs -0n1 git blame -w -C
       | sed -r 's/^[^(]+\((.*) [0-9]{4}-.*/\1/'
       | sed -r 's/ +$//'
       | sort -f
       | uniq -c
       | sort -nr
4

1 回答 1

13

我怀疑它更多的是关于' \',它需要加倍。

我用 ' ' 尝试了你的别名,\\没有任何错误消息。

impact = !git ls-files -z
       | xargs -0n1 git blame -w -C
       | sed -r 's/^[^(]+\\((.*) [0-9]{4}-.*/\\1/'
       | sed -r 's/ +$//'
       | sort -f
       | uniq -c
       | sort -nr
于 2011-10-18T08:20:01.823 回答