Skip to content

Instantly share code, notes, and snippets.

@jjhamshaw
Last active September 13, 2017 13:44
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 jjhamshaw/b1bbe06df83e12945307 to your computer and use it in GitHub Desktop.
Save jjhamshaw/b1bbe06df83e12945307 to your computer and use it in GitHub Desktop.
scripts to clean up local git branches for a given repository
# safe delete branches
# (deletes all MERGED branches, except dev and master)
git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
# delete branches
# (deletes all branches, except dev and master)
git branch | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment