Created
January 23, 2024 14:31
-
-
Save michaelb87/146e170221cc0c1dc6329693f69b81bd to your computer and use it in GitHub Desktop.
Place in .git/hooks/pre-commit
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 | |
# NOTE: make file executable with: | |
# chmod +x .git/hooks/pre-commit | |
# Get the current branch name | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
# Check if the current branch is 'main' | |
if [ "$branch" = "main" ]; then | |
echo "You can't commit directly to main branch." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment