Skip to content

Instantly share code, notes, and snippets.

@ederparaiso
Last active June 11, 2018 17:19
Show Gist options
  • Save ederparaiso/b143361ae48b7274d1bad3f10dc7d186 to your computer and use it in GitHub Desktop.
Save ederparaiso/b143361ae48b7274d1bad3f10dc7d186 to your computer and use it in GitHub Desktop.
Removes all branches that don't exist in remote repo anymore
#!/bin/bash
cd $1
git checkout master
git fetch --prune
OLD_BRANCHES=$(git branch -v | grep gone | cut -d " " -f3)
for branch in ${OLD_BRANCHES}; do
git branch -D ${branch}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment