Created
February 22, 2012 09:56
-
-
Save tandibar/1883721 to your computer and use it in GitHub Desktop.
Check wheather a branch has differences with master or not
This file contains hidden or 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 | |
for branch in $(git branch -a | grep "remotes/origin/" | grep -v "master" | sed 's|remotes/||') | |
do | |
echo "checking $branch for unmerged changes" | |
if git diff --exit-code master...$branch > /dev/null | |
then | |
echo "no commits found which were not already merged into master" | |
echo "should i delete the branch $branch?(y/n): " | |
read answer | |
if [ $answer = "y" ] | |
then | |
echo "deleting $branch" | |
git branch -d -r $branch | |
git push origin :`echo $branch | sed 's|origin/||'` | |
else | |
echo "not deleting $branch" | |
fi | |
else | |
echo "--> DIFFERENCES found, should not be deleted" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment