Skip to content

Instantly share code, notes, and snippets.

@marekpiechut
Created December 14, 2017 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marekpiechut/a1d975a840cc7ec184d132f7dc0468a6 to your computer and use it in GitHub Desktop.
Save marekpiechut/a1d975a840cc7ec184d132f7dc0468a6 to your computer and use it in GitHub Desktop.
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