3

I'm trying to alias the command:

git branch --merged | grep -v "\*" | grep -v master | xargs -n 1 git branch -d

Taken from this answer

This is my .gitconfig file:

[credential]
    helper = wincred
[user]
    name = Doron Grinzaig
    email = doron@doNotSpamMe.Suckers
[push]
    default = simple
[alias]
    db = git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
    unstage = reset HEAD --

But now when I try to edit the .gitconfig file I get the error:

$ git config --global --edit
fatal: bad config file line 9 in C:\Users\Doron Grinzaig/.gitconfig

I was told I need to use ! for running bash scripts as git alias, but the following returned the same error:

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

I'm using git bash for windows.

James Monger
  • 8,229
  • 5
  • 44
  • 81
gdoron is supporting Monica
  • 136,782
  • 49
  • 273
  • 342
  • The "bad config file" error could be here for some other reason : bad EOL marker (`\r\n` instead of `\n`, or the reverse, I don't know what git expects on windows), maybe an unbreakable space somewhere ... Try deleting and re-writing the whole [alias] section. – LeGEC Feb 03 '16 at 08:46

1 Answers1

3

Try escaping the quotes and backslash in the first grep command:

[alias]
    db = !git branch --merged | grep -v \"\\*\" | grep -v master | grep -v dev | xargs -n 1 git branch -d
Gary McLean Hall
  • 854
  • 6
  • 14