Created
March 22, 2018 02:09
-
-
Save manhdaovan/3c13c80b06de7bc16ab4ed8bbf482d65 to your computer and use it in GitHub Desktop.
Bash: Delete local branch before time
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
| # Usage: delete_local_branch number_of_weeks_ago | |
| # Eg: delete_local_branch 4 | |
| function delete_local_branch() { | |
| for k in $(git branch | sed /\*/d); do | |
| if [ -n "$(git log -1 --before='$1 week ago' -s $k)" -a "$k" != "develop" -a "$k" != "master" -a "$k" != "staging" ]; then | |
| echo "Delete $k" | |
| git branch -D $k | |
| fi | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment