Created
October 22, 2014 19:15
-
-
Save andrewberls/7bc712d8e57b370c8631 to your computer and use it in GitHub Desktop.
Prevent git pushes directly to master. Install to .git/hooks/pre-push
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 | |
# Pre-push hook to prevent pushes to master branch. | |
pushed_branch=`git rev-parse --abbrev-ref HEAD` | |
if [[ "$pushed_branch" == "master" ]] | |
then | |
echo "[Notice] Pre-push hook preventing push to master. Create a feature branch instead." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that this needs chmod 700, and on my box, requires
#!/bin/bash
, not#!/bin/sh
Other than that works great, thank you for finding this!