Skip to content

Instantly share code, notes, and snippets.

@aphahn
Created March 20, 2013 07:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aphahn/5202851 to your computer and use it in GitHub Desktop.
Save aphahn/5202851 to your computer and use it in GitHub Desktop.
Tired of cleaning out your merged Gerrit branches by hand? Freaked out when git tells you your branches aren't fully merged yet (but it's actually fine because it changed SHA1 at rebase time)? Just run `gerrit-clean` in your repository and it will delete branches that have been merged into your master.
function gerrit-clean () {
for branch in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
if git log master|ack -1 "$(git log "$branch"|ack -1 Change-Id)" > /dev/null; then
if [ "$branch" != "master" ]; then
git branch -D "$branch"
fi
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment