Last active
October 20, 2017 21:05
-
-
Save iainconnor/b5ef2c0e216ad26a748dd97721300720 to your computer and use it in GitHub Desktop.
Custom cleanup command for git.
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/sh | |
source "$(git --exec-path)/git-sh-setup" | |
if git diff-index --quiet HEAD --; then | |
git checkout master | |
git remote update origin --prune | |
for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote &> /dev/null; done | |
git pull --all | |
git branch -r --merged master | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin &> /dev/null | |
git branch --merged master | egrep -v "(^\*|master)" | xargs -n 1 git branch -d &> /dev/null | |
else | |
echo "You have pending changes. Finish them before cleaning up." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment