Skip to content

Instantly share code, notes, and snippets.

@Whitespace
Forked from jessedearing/cleanup.sh
Created August 28, 2012 22:56
Show Gist options
  • Save Whitespace/3505099 to your computer and use it in GitHub Desktop.
Save Whitespace/3505099 to your computer and use it in GitHub Desktop.
Git branch cleanup
git checkout master
git fetch
git remote prune origin
git branch --merged master | grep -v 'master$' | xargs git branch -d
echo "The following remote branches are fully merged and will be removed:"
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$'
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$' | xargs -I% git push origin :%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment