***
- Create file
.git/hooks/pre-commit
#!/bin/sh
# .git/hooks/pre-commit
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "main" ]; then
echo "You can't commit directly to master branch"
exit 1
fi
- make it executable
chmod +x .git/hooks/pre-commit
- Enjoy