Created
September 28, 2019 19:41
-
-
Save PaperNick/08ba06b2e9e1f7d94150594d88689fff to your computer and use it in GitHub Desktop.
Revisions
-
PaperNick created this gist
Sep 28, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ ## How to install ```bash #!/bin/bash current_branch="$(git symbolic-ref --short HEAD)" FORBIDDEN_BRANCHES=(master develop) for forbidden_branch in "${FORBIDDEN_BRANCHES[@]}"; do if [ "$current_branch" == "$forbidden_branch" ]; then echo 'You are not allowed to commit in this branch.' exit 1 fi done ``` 1. Copy the content of this hook in `/your/project/.git/hooks/pre-commit` 2. Make the pre-commit hook executable `chmod +x /your/project/.git/hooks/pre-commit`