Created
July 13, 2020 18:30
-
-
Save moxley/c24b285576fc3d9f75a580a5392cbf90 to your computer and use it in GitHub Desktop.
Script that cleans up local repo after merging a PR
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
#!/bin/sh | |
# Example: | |
# gclean master | |
trunk="$1" | |
if [ -z "${trunk}" ]; then | |
echo "Usage: $0 TRUNK" | |
exit 2 | |
fi | |
if ( git branch | grep "$trunk" ); then | |
true | |
else | |
echo "Did not find $trunk" | |
exit 2 | |
fi | |
git checkout "$trunk" | |
git pull | |
git branch --merged | egrep -v "(^\*|$trunk)" | xargs git branch -d | |
git branch -r --merged | egrep -v "(^\*|$trunk)" | xargs git branch -r -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment