Skip to content

Instantly share code, notes, and snippets.

@kylefritz
Created May 1, 2012 00:10
Show Gist options
  • Save kylefritz/2563866 to your computer and use it in GitHub Desktop.
Save kylefritz/2563866 to your computer and use it in GitHub Desktop.
Delete branches that have been merged into HEAD
#all local branches that are merged into HEAD
git branch -d `git branch --merged | grep -v '^*' | tr -d '\n'`
#Delete all remote branches that are merged into HEAD
#jump back to master
git co master
#get rid of all local branches not on origin
git remote prune origin
#list merged branches and push up
git push origin `git branch -r --merged | grep 'origin' | grep -v '/master$' | sed 's/origin\//:/g' | tr -d '\n'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment