-
-
Save elhoyos/4024800 to your computer and use it in GitHub Desktop.
Delete all git branches that have been already merged into master
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
git branch -a --merged master | # merged to master | |
grep -v '>' | # branch pointers exception | |
grep -v 'master\|develop' | # exceptions | |
xargs -L1 | # get the first column | |
tee >(grep origin | | |
awk '{split($0,a,"/"); print a[3]}' | | |
xargs git push origin --delete) | # remove remotes | |
xargs git branch -d # remove local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment