Created
June 15, 2015 18:26
-
-
Save alecklandgraf/425ec93cdc225f5f55fd to your computer and use it in GitHub Desktop.
git pre-commit hook to prevent committing to master
This file contains hidden or 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 | |
| branch=`git symbolic-ref --short HEAD` | |
| # allow user input within pre-commit hook | |
| exec < /dev/tty | |
| if [ $branch == "master" ]; then | |
| echo "Commit to master [yes|no]?" | |
| read yesno | |
| if [ "$yesno" == "yes" ]; then | |
| echo "commiting" | |
| else | |
| echo "aborting" | |
| exit 1 | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment