Created
July 7, 2015 18:32
-
-
Save alexsoble/7d0fcbb0f58cc592b556 to your computer and use it in GitHub Desktop.
A git hook to help you make good decisions about rebasing
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
askAboutGitBranches() { | |
echo "Is the branch you want to rebase already pushed to GitHub? (y/n) " | |
read RESPONSE | |
if [ "$RESPONSE" = "n" ]; then | |
rebaseAway | |
elif [ "$RESPONSE" = "y" ]; then | |
echo "Are you the only one committing on this branch? (y/n)" | |
read RESPONSE_2 | |
if [ "$RESPONSE_2" = "y" ]; then | |
rebaseAway | |
elif [ "$RESPONSE_2" = "n" ]; then | |
stopThatRebase | |
else | |
wut | |
fi | |
else | |
wut | |
fi | |
} | |
rebaseAway() { | |
echo "Go ahead, rebase away!" | |
return 0 | |
} | |
stopThatRebase() { | |
echo "Don't rebase, just push/merge." | |
echo "Otherwise you'll end up with messy history." | |
return 1 | |
} | |
wut() { | |
echo "Wut?" | |
return 1 | |
} | |
askAboutGitBranches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment