4

Can anyone help me figure out what is wrong with this line in the .gitconfig file?

[alias]
db = !git branch --merged | grep -v "\*" | xargs -n 1 git branch -d

The command by itself works, I was following along this post (How can I delete all git branches which have been merged?)

But when I run the alias 'git db' it will fail with 'fatal: bad config file line 22' which points to that line in my .gitconfig file

Community
  • 1
  • 1
d3ming
  • 6,860
  • 4
  • 25
  • 31

1 Answers1

5

To expand on the comment by MrTux: quotes ("") have special meaning in a Git config file. If you want to use them in a config value, you have to escape them and then quote the entire value, like this:

db = "!git branch --merged | grep -v \"*\" | xargs -n 1 git branch -d"
Jan Krüger
  • 15,896
  • 3
  • 54
  • 50
  • And so do backslashes, e.g.: `foobar '!@#$\"'\'` would become `"foobar '!@#$\\\"'\\'"` – Walf Sep 21 '17 at 00:10