Why is this line of poor configuration for my .gitconfig?

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

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

+6
source share
1 answer

I would recommend doing this bash script in your PATH instead, and then calling that script instead of your git alias (or if it is in your PATH anyway, just name the file git-bd ).

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

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

Make the executable with the command:

 chmod +x ~/bin/git-bd 

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

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

And you can just call git-bd directly or add an alias to your .gitconfig like this:

 bd = "!git-bd" 

To add to this answer, the reason you get the wrong configuration error might be caused by backslashes. git -config will read them as is, so you need to avoid them again with a second backslash.

+5
source

Source: https://habr.com/ru/post/1011560/


All Articles