Created
July 10, 2018 16:41
-
-
Save phillijw/98b54553a557bdb9dec9e56b7a58e916 to your computer and use it in GitHub Desktop.
git cleanup alias
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
Calling "git cleanup" will delete local branches that have already been merged into origin/master. It skips master, staging, and dev because we don't want to delete those in normal circumstances. | |
$ git config --global alias.cleanup '!git branch --merged origin/master | egrep -v "(^\*|master|staging|dev)" | xargs git branch -d' |
The ^\*
is checking to make sure it doesn't try to delete the current branch you're on (which gets displayed with a * next to the name)
Experiment using this command in a terminal: git branch --merged origin/master | egrep -v "(^\*|master|staging|dev)" | xargs echo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then just call it with
git cleanup