Skip to content

Instantly share code, notes, and snippets.

@alexsoble
Created July 7, 2015 18:32
Show Gist options
  • Save alexsoble/7d0fcbb0f58cc592b556 to your computer and use it in GitHub Desktop.
Save alexsoble/7d0fcbb0f58cc592b556 to your computer and use it in GitHub Desktop.
A git hook to help you make good decisions about rebasing
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