Skip to content

Instantly share code, notes, and snippets.

@holodigm
Created October 26, 2016 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holodigm/391efbab004bbe6f8643a7e44713e2c0 to your computer and use it in GitHub Desktop.
Save holodigm/391efbab004bbe6f8643a7e44713e2c0 to your computer and use it in GitHub Desktop.
clean a git repo
git checkout master
git fetch
git remote prune origin
git branch --merged master | grep -v 'master$' | xargs git branch -d
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$'
read -p "Continue (y/n)? "
if [ "$REPLY" == "y" ]
then
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$' | xargs -I% git push origin :%
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment