5

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
  • 8,496
  • 5
  • 31
  • 33

1 Answers1

6

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
  • 17,870
  • 3
  • 59
  • 51
  • And so do backslashes, e.g.: `foobar '!@#$\"'\'` would become `"foobar '!@#$\\\"'\\'"` – Walf Sep 21 '17 at 00:10