Created
September 9, 2016 14:52
-
-
Save MichaelPereira/7ce7c73d2f7325cf08da8450fdf10d94 to your computer and use it in GitHub Desktop.
Script to clean-up remote branches that have already been merged to master.
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 | |
# Format for excluded branches: "branch|branch|branch..." | |
excluded_branches="master|gh-pages|HEAD" | |
for branch in $(git branch -r | tr -d ' ' | sed -e 's/->.*//' | egrep -v "${excluded_branches}"); do | |
if git branch -r --contains "${branch}" | grep -q master; then | |
git push origin ":${branch#origin/}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment