Reputation: 6295
I have a command to delete local copies of branches that have been merged into 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 like to add an alias to my .gitconfig
but I cannot get one to work - I think I'm messing up the escaping. How can I get this command working, or a command that accomplishes the same thing?
Upvotes: 1
Views: 184
Reputation: 17381
Regarding how to create an alias for a compound command or script, this should do:
[alias]
branch-clear = !git for-each-ref ... | ...
Or via a function:
[alias]
branch-clear = "!f() { git for-each-ref ... | ...; }; f"
Upvotes: 1