Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitConfig: bad config for shell command

I'm trying to set up an alias, as I have many.

For some reason, this one does not work. Any idea?

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

Command works fine by itself:

$ 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
like image 422
shkschneider Avatar asked Jul 16 '26 03:07

shkschneider


1 Answers

Backslash ("\") characters are read by git itself in your config. Just escape them again with a second backslash and it will work:

t = "!git log --decorate --oneline | egrep '^[0-9a-f]+ \\(tag: ' | sed -r 's/^.+tag: ([^ ]+)[,\\)].+$/\\1/g'"
like image 55
jbowes Avatar answered Jul 18 '26 18:07

jbowes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!