Forked from jasonrudolph/git-branches-by-commit-date.sh
Last active
December 30, 2015 07:09
-
-
Save maskas/e8218182ac583b547692 to your computer and use it in GitHub Desktop.
Remove all remote branches that are merged to master, except 20 last ones. Sort by most recent commit date.
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
#Remove remote branches, that are merged to master. Leave 20 latest branches just in case. | |
git pull | |
for branch in `git branch -r --merged origin/master | grep -v HEAD`;do echo -e `git show --format="%at" $branch | head -n 1` \\t$branch; done | sort -r | cut -c 20- | awk 'NR>20' | while read line ; do git push origin --delete $line; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment