Why is this a bad config line for my .gitconfig?

bd = "!f() { git branch --merged | egrep -v '(^\*|master|dev)' | xargs git branch -d }; f"

I’m trying to alias a git command to remove all of my local merged branches.
When I put the bash command into my gitconfig as above, git complains about a bad config line:
fatal: bad config line 26 in file /Users/johnsona/.gitconfig

  • Where exactly Git Bash for Windows' prompt is defined?
  • Why am I getting “: No such file or directory” when trying to execute a bash script?
  • .gitconfig not following bash alias for default editor command?
  • store the values from command into an array bash
  • Git bash-completion with filename support?
  • Adding git alias to .bash_profile not working
  • Is it possible to store only a checksum of a large file in git?
  • Multiple github accounts: what values for Host in .ssh/config?
  • How to unmerge a Git merge?
  • How to set specific path permissions using Git?
  • Git rebase continually fails and requires manual merge intervention
  • Is there a way to do “git checkout” and *force* the argument to be interpreted as a branch name?
  • One Solution collect form web for “Why is this a bad config line for my .gitconfig?”

    I’d recommend making this a bash script in your PATH instead, and then calling that script in your git alias instead (or if it’s in your PATH anyway, just name the file git-bd).

    For example, make the file ~/bin/git-bd

    #!/usr/bin/env bash
    git branch --merged | egrep -v '(^\*|master|dev)' | xargs git branch -d

    Make the file executable with the command:

    chmod +x ~/bin/git-bd

    And make sure your .bashrc, .bash_profile or .bash_login file has the line:

    export PATH="$HOME/bin:$PATH"

    And you can either just call git-bd directly, or add the alias in your .gitconfig like so:

    bd = "!git-bd"

    To add to this answer, the reason you are getting a bad config error may be due to the back-slashes. The git-config will read them as is, so you need to escape them again with a second backslash.

    Git Baby is a git and github fan, let's start git clone.