When using Git, I find myself doing a lot of what I call "exploratory merging" into a throwaway local branch. This is to preview what a scary merge might look like master, or to isolate a bug in a staging environment by selectively merging in certain of the branches that have been deployed.
The names of my throwaway branches always start with an underscore, so I can easily see them when I git branch
. Below is a Bash one-liner (aliased as git purge
) that deletes unmerged branches whose names start with "_".
[alias]
purge = !git branch --no-merged | tr -d "* " | grep ^_ | xargs git branch -D