Created
October 28, 2016 07:07
-
-
Save bobmaerten/ef483cd0c906e380c42363b5ebf8725e to your computer and use it in GitHub Desktop.
Merged tracked branches pruning to keep .git/config file clean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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