Skip to content

Instantly share code, notes, and snippets.

@IslamAzab
Last active May 17, 2016 18:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IslamAzab/242103318c30c28be45b to your computer and use it in GitHub Desktop.
Save IslamAzab/242103318c30c28be45b to your computer and use it in GitHub Desktop.
# remove all merged branches except "develop" branch
git branch -r --merged | grep -v master | grep -v '^ develop$' | sed 's/origin\///' | xargs -n 1 git push --delete origin
# to remove them
git branch -r --merged | grep -v master | grep -v '^ development$' | sed -e 's/origin\///' | xargs -n 1 git branch --delete
# track all remote branches locally
for remote in `git branch -r | grep -v /HEAD`; do git checkout --track $remote ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment