Skip to content

Instantly share code, notes, and snippets.

@jesselcampbell
Last active September 11, 2017 17:48
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 jesselcampbell/426749939e4ae8766864dd5b9ab183f5 to your computer and use it in GitHub Desktop.
Save jesselcampbell/426749939e4ae8766864dd5b9ab183f5 to your computer and use it in GitHub Desktop.
Git clean: delete merged branches
# Source: https://stevenharman.net/git-clean-delete-already-merged-branches
# To delete local branches which have already been merged into master
$ git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
# You can omit the master branch argument to remove local branches which have already been merged into the current HEAD
$ git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
# To update the local list of remote branches
$ git remote update origin --prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment