Last active
August 29, 2015 14:02
-
-
Save mhaylock/b7b83911d779f4b351da to your computer and use it in GitHub Desktop.
Cleaning up old branches from a Git repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update local remote refs, and delete all local remote refs that have been | |
# deleted on Github: | |
$ git fetch -p | |
# Switch to a primary branch (i.e. 'api' or 'master'), you will use this branch | |
# to find all merged branches that you will delete: | |
$ git checkout api | |
# Find all branches that have been merged with this branch, and delete them. | |
# NOTE: This might result in your master branch being deleted when run from | |
# another branch already merged with master. This may or may not be a bad thing | |
# for you - be aware and decide if you want to avoid that (note that you can | |
# easily re-checkout the master branch to match your remote): | |
$ git branch --merged | grep -v "\*" | xargs -n 1 git branch -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment