Last active
October 13, 2016 06:32
-
-
Save 5t111111/be2f369a19502518e913 to your computer and use it in GitHub Desktop.
git pre-push hook to prevent direct pushing 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 | |
| # An example hook script to prevent direct pushing to master | |
| while read local_ref local_sha1 remote_ref remote_sha1 | |
| do | |
| # If you also want to prevent direct pushing to branches in addition to master branch, | |
| # just copy and paste the below and replace "master" with the branch name you desire. | |
| # ==========> Copy & paste START | |
| if [[ "${remote_ref##refs/heads/}" = "master" ]]; then | |
| cat << EOT | |
| ============================================================ | |
| Pushing to the master branch is not allowed | |
| ============================================================ | |
| EOT | |
| exit 1 | |
| fi | |
| # <========== Copy & paste END | |
| done | |
| exit 0 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this overwrites the existing pre-push