GitConfig:shell命令配置错误

shk*_*der 3 git git-config git-alias

我正在尝试设置别名,因为我有很多。

出于某种原因,这是行不通的。任何的想法?

[alias]
t = "!git log --decorate --oneline | egrep '^[0-9a-f]+ \(tag: ' | sed -r 's/^.+tag: ([^ ]+)[,\)].+$/\1/g'"
Run Code Online (Sandbox Code Playgroud)

命令本身可以正常工作:

$ git log --decorate --oneline | egrep '^[0-9a-f]+ \(tag: ' | sed -r 's/^.+tag: ([^ ]+)[,\)].+$/\1/g'
1.0.0
0.9.0
...
$ git t
fatal: bad config file line 28 in /Users/alanschneider/.gitconfig
Run Code Online (Sandbox Code Playgroud)

jbo*_*wes 5

\git本身会在配置中读取反斜杠(“ ”)字符。只需使用第二个反斜杠再次转义它们,它将起作用:

t = "!git log --decorate --oneline | egrep '^[0-9a-f]+ \\(tag: ' | sed -r 's/^.+tag: ([^ ]+)[,\\)].+$/\\1/g'"
Run Code Online (Sandbox Code Playgroud)