#!/bin/sh # https://gist.github.com/shabith/653a29ed1e9835e71fb0a4662523cf85 # git hook with confimation message # this pre-push git hook will show a confirmation message and according to the answer (y or n) by user it will proceed or exit. # Please note that this has been tested only in OSX terminal # Allow us to read user input below, assigns stdin to keyboard exec < /dev/tty branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') if [ "master" = $branch ]; then while true; do echo "\n"; read -p "🚨 šŸ‘® Did you merge with the upstream/master branch? (Y/n) " yn if [ "$yn" = "" ]; then yn='N' fi case $yn in [Nn] ) echo "\nšŸ™…ā€ Please merge with upstream/master branch before pushing to orgin/master. Thanks!\n"; exit 1;; [Yy] ) echo "\nšŸ‘šŸ½ All good then. Thanks!\n"; break; exit 0;; * ) echo "\nšŸ’€ Please answer y or n for Yes šŸ‘šŸ½ or No šŸ‘ŽšŸ½ \n"; exit 1;; esac done fi exit 0