What are Git hooks?
bash
# .git/hooks/pre-commit
#!/bin/sh
npm run lint
npm run test
# If fails, commit is abortedWith Husky:
json
{
"husky": {
"hooks": {
"pre-commit": "npm run lint",
"pre-push": "npm test"
}
}
}Common hooks:
- pre-commit
- pre-push
- post-merge
- commit-msg
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.