Skip to content

Instantly share code, notes, and snippets.

@iamsk
Last active March 12, 2018 03:24
Show Gist options
  • Save iamsk/c49a155755de18f4c19ab9217544ad35 to your computer and use it in GitHub Desktop.
Save iamsk/c49a155755de18f4c19ab9217544ad35 to your computer and use it in GitHub Desktop.

local branches

List local branches which have been merged in master

git branch --merged master

Remove these local merged branches, make sure you are on master and updated to newest

git checkout master && git pull origin master

git branch --merged master | egrep -v "(^\*|master)" | xargs git branch -d

remote branches

List remote branches which have been merged in master

git branch -r --merged master

Remove these remote branches, make sure you are on master and updated to newest

git checkout master && git pull origin master

git branch -r --merged master | egrep -v "(^\*|master)" | sed 's_ *origin/__' | xargs -I% git push origin --delete %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment