Hooks in `.git/hooks` are not shared with the team. How do you distribute them?
IntermediateScenarioProtection, Hooks and Policy
Answer
Situation read → .git is never part of the repository.
What I'd do →
- Commit hooks to a tracked folder such as
.githooks/. - Point Git at it:
git config core.hooksPath .githooks. - Automate that in a bootstrap script or
make setup. - Or use pre-commit, Husky or lefthook, which install themselves.
Why → core.hooksPath is local config, so each clone must run it once.
Interview tip → Because hooks are local, always duplicate critical checks in CI.
More on Protection, Hooks and Policy
You are asked to protect `main`. Which rules do you turn on?BeginnerClassic branch protection or repository rulesets: which do you use?IntermediateA required status check never reports and the PR is stuck as "Expected — Waiting for status".IntermediateProduction is down and the fix needs to merge now, but approvals are required.IntermediateYou want to stop developers from committing obvious mistakes like debug prints, trailing whitespace or secrets.BeginnerA developer bypasses your hook with `git commit --no-verify`. How do you enforce the rule anyway?Intermediate