What are hooks in Git?
Short answer: Can you give examples? Git hooks are scripts that run automatically when specific Git events occur (like committing or pushing). They live inside .git/hooks/. Common examples: pre-commit: Run linting or unit tests before a commit # .git/hooks/pre-commit npm run lint || exit 1 pre-push: Prevent pushes to main if [ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]; then echo "You can't push directly to main!" exit 1 fi…
Explain a bit more
Example: In a team, we set a pre-commit hook to check code formatting with ESLint before any commit — ensuring consistency across all contributors.
Real-world example (ShopNest)
ShopNest’s team uses GitHub PRs with reviews and CI checks so broken builds never reach production unnoticed.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png