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

  • How to tell if you're in a git-svn repo command line?
  • Bash function to find all Git commits in which a file (whose name matches a regex) has *changed*
  • How to upgrade Gitlab 7 to 8 with old backup
  • Android Studio: How to integrate Git from Windows 10 Ubuntu bash?
  • git-upload-pack: command not found
  • git push not working inside a cron job
  • Git find stale files
  • Git rebase develop before merging to develop?
  • What are the pros and cons of using a trunk-based Vs feature-based workflow in Git?
  • Using git within an svn checkout? (without git-svn)
  • Git pushing to remote GitHub repository as wrong user
  • No submodule mapping found in .gitmodules for path
  • 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.