Created
January 23, 2012 09:25
-
-
Save clauswitt/1662029 to your computer and use it in GitHub Desktop.
Remove unused tracking branches
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
#!/bin/bash | |
TMPFILE=".tmpGitRemotes" | |
REMOTENAME="origin" | |
COMMIT=$1 | |
git fetch | |
git branch -a --merged |grep "remotes/$REMOTENAME/" > $TMPFILE | |
if [[ $COMMIT == "commit" ]]; then | |
echo "deleting git branches" | |
else | |
echo "dry run - call with commit to delete branches" | |
fi | |
while read line; do | |
BRANCHNAME=`basename $line` | |
if [[ $BRANCHNAME -ne "master" ]]; then | |
if [[ $COMMIT == "commit" ]]; then | |
echo "running: git push $REMOTENAME :$BRANCHNAME" | |
git push $REMOTENAME :$BRANCHNAME | |
else | |
echo "git push $REMOTENAME :$BRANCHNAME" | |
fi | |
fi | |
done<$TMPFILE | |
rm $TMPFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment