Created
May 7, 2012 08:48
-
-
Save edorian/2626744 to your computer and use it in GitHub Desktop.
Cleanup remote branches not merged with "development" that are stale for 4 weeks. But don't clean master
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 | |
LOG="tee -a /tmp/branch-cleanup.log" | |
git checkout development | |
git fetch | |
git remote prune origin | |
branchlist=`git branch -r --merged development | sed 's/ *origin\///' | grep -v 'master$' | grep -v 'development$'` | |
for branch in $branchlist | |
do | |
commitHappendInTheLast4Weeks=`git log -n1 --since="4 weeks ago" "origin/"$branch` | |
if [ "$commitHappendInTheLast4Weeks" == "" ] | |
then | |
echo "To be deleted: "$branch | $LOG | |
echo `git log -n1 "origin/"$branch` | $LOG | |
git push origin ":"$branch | $LOG | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment