cloudenv / git-hooks /pre-commit
Vishvam10
initial space commit
b404de3
Raw History Blame Contribute Delete
389 Bytes
#!/bin/bash
printf "\nRunning pre-commit hook ..."
current_branch=$(git symbolic-ref --short HEAD)
if [[ "$current_branch" == "main" || "$current_branch" == "master" ]]; then
printf "\n🔴 Direct commits to '$current_branch' are not allowed !"
printf "\nPlease commit to a feature branch and open a pull request."
exit 1
fi
printf "\n✅ Pre-commit checks passed !"
exit 0