Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jbbarth
Created October 18, 2021 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbbarth/332ce541b345ab7f5bba1cce2f6a7983 to your computer and use it in GitHub Desktop.
Save jbbarth/332ce541b345ab7f5bba1cce2f6a7983 to your computer and use it in GitHub Desktop.
gp() {
current_branch=$(git rev-parse --abbrev-ref HEAD)
if echo "$current_branch" | grep -qE '^(master|main|devel)$'; then
read "answer?You're about to push to a MAIN branch, are you sure? [y/N] "
if ! echo "$answer" | grep -qE '^y'; then
echo "aborting..."
return
fi
fi
git push origin HEAD
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment