Skip to content

Instantly share code, notes, and snippets.

@phillijw
Created July 10, 2018 16:41
Show Gist options
  • Save phillijw/98b54553a557bdb9dec9e56b7a58e916 to your computer and use it in GitHub Desktop.
Save phillijw/98b54553a557bdb9dec9e56b7a58e916 to your computer and use it in GitHub Desktop.
git cleanup alias
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'
@phillijw
Copy link
Author

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