Last active
October 11, 2015 11:58
-
-
Save codeprogression/3855974 to your computer and use it in GitHub Desktop.
Removing local and remote branches (for origin remote, while excluding upstream remote)
This file contains hidden or 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
# To delete all merged local branches (excluding non-origin remotes) | |
git branch --merged master | grep -v 'master$' | xargs git branch -d | |
# To delete all merged remote branches (excluding non-origin remotes) | |
git branch -r --merged master | grep 'origin' | sed 's/ *origin\///' | grep -v 'master$' | xargs -i% git push origin :% | |
# To remove orphaned remote branch references | |
git remote | xargs -I% git remote prune % |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment