Skip to content

Instantly share code, notes, and snippets.

@jonathanlarsen
Forked from malclocke/gist:943565
Last active June 12, 2018 15:10
Show Gist options
  • Save jonathanlarsen/4732175 to your computer and use it in GitHub Desktop.
Save jonathanlarsen/4732175 to your computer and use it in GitHub Desktop.
Delete remote merged into master
git branch -r --merged | awk -F'/' '/^ *origin/{if(!match($0, /(>|master)/)){print $2}}' | xargs git push origin --delete
Delete local merged into current branch
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
Delete all remote not in egrep
git branch -a | egrep "remotes/origin/" | cut -d "/" -f 3- | egrep -v "(master|develop)" | xargs -n 1 git push --delete origin
Delete all local not in egrep
git branch | egrep -v "(master|develop)" | xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment