Created
April 24, 2012 13:45
-
-
Save 9z0b3t1c/2479777 to your computer and use it in GitHub Desktop.
Clean up git branches
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
# This has to be run from master | |
git checkout master | |
# Update our list of remotes | |
git fetch | |
git remote prune origin | |
# Remove local fully merged branches | |
git branch --merged master | grep -v master | grep -v am-test | grep -v production | xargs git branch -d | |
# Take a look at the list of remote branches which haven't been merged into master | |
git branch -r --merged master | sed 's/ *origin\///' | grep -v master | grep -v production | grep -v am-test | |
# Remove merged user story branches: | |
git branch -r --merged master | sed 's/ *origin\///' | grep US* | xargs -I% git push origin :% | |
# Remove merged defect branches | |
git branch -r --merged master | sed 's/ *origin\///' | grep DE* | xargs -I% git push origin :% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment