Skip to content

Instantly share code, notes, and snippets.

@saniyat
Created October 10, 2018 20:58
Show Gist options
  • Save saniyat/8bb74680a6348b0e38689443c1867d4c to your computer and use it in GitHub Desktop.
Save saniyat/8bb74680a6348b0e38689443c1867d4c to your computer and use it in GitHub Desktop.
GIT: Branch delete and cleanups
// 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