Make a git alias to remove all local merged branches -


i have command delete local copies of branches have been merged develop:

git for-each-ref --format='%(refname:short)' refs/heads/ | grep -v develop | xargs -l1 -i '{}' sh -c "git merge-base --is-ancestor {} develop && git branch -d {}" 

i'd add alias .gitconfig cannot 1 work - think i'm messing escaping. how can command working, or command accomplishes same thing?

regarding how create alias compound command or script, should do:

[alias]   branch-clear = !git for-each-ref ... | ... 

or via function:

[alias]   branch-clear = "!f() { git for-each-ref ... | ...; }; f" 

Comments