Skip to content

Instantly share code, notes, and snippets.

@bobmaerten
Created October 28, 2016 07:07
Show Gist options
  • Save bobmaerten/ef483cd0c906e380c42363b5ebf8725e to your computer and use it in GitHub Desktop.
Save bobmaerten/ef483cd0c906e380c42363b5ebf8725e to your computer and use it in GitHub Desktop.
Merged tracked branches pruning to keep .git/config file clean
#!/usr/bin/env bash
current_branch=$(git rev-parse --abbrev-ref HEAD)
[ $current_branch == "master" ] || git checkout master
git fetch --all -p --tags
git pull
for BRANCH in $(git branch --merged origin/master | grep -v "\* master")
do
git branch --unset-upstream $BRANCH
git branch -d $BRANCH
done
[ $current_branch == "master" ] || git checkout -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment