Prevent accidental pushes to main.
Section: Hook Snippets
Block direct pushes to main
sh
bash
#!/usr/bin/env sh
branch="$(git symbolic-ref --short HEAD)"
[ "$branch" = "main" ] && echo "Direct pushes to main are blocked." && exit 1
exit 0Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Hook Snippets