Created
June 8, 2016 09:39
-
-
Save jacquesbh/4320cba644cf29a4217ede72065b1754 to your computer and use it in GitHub Desktop.
Clean the branches in git repository according to the remote
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
#!/bin/bash | |
# Usage: ./git_clean_branches.sh REPOSITORY_PATH | |
# Go to the directory | |
cd "$1" | |
# Delete branches, but keep develop, master and the current branch | |
git remote prune origin | |
git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | xargs -n 1 git branch -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment