Created
October 10, 2018 20:58
-
-
Save saniyat/8bb74680a6348b0e38689443c1867d4c to your computer and use it in GitHub Desktop.
GIT: Branch delete and cleanups
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
// Delete all merged branches both from local and remote. | |
git branch -r --merged | grep origin | egrep -v '>|master' | cut -d/ -f2- | xargs git push origin --delete | |
// Clean deleted branches. | |
git fetch -p && for branch in `git branch -vv | grep ': gone]' | gawk '{print $1}'`; do git branch -D $branch; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment