Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
GIT branches cleanup procedure
#Wipe all branches already merged on origin
git remote prune origin
#Remove all branches already merged to master
git branch --merged master | grep -v 'master' | xargs git branch -d
#Now let's check what's left
git branch
#Remove all other branches except master, leave-me and im-also-important
!!!WARNING: WILL DELETE UNMERGED BRANCHES, DOUBLE CHECK!!!
git branch | grep -Ev "master|leave-me|im-also-important" | xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment