Menu

Git Hooks Not Running for Teammates? Husky vs Lefthook vs pre-commit
📰

Git Hooks Not Running for Teammates? Husky vs Lefthook vs pre-commit

DEV Community: cicd·Libme·15 days ago
#LctrQI4r
#devtocicd#devto#dev#hooks#commit
Reading 0:00
15s threshold

Git hooks don't run for teammates because .git/hooks/ is never committed, so every clone starts with no hooks at all. Husky, lefthook, and pre-commit all solve this the same way: the hook definitions live in the repo, and an install step points Git at them. Pick husky if your repo is already a Node project, lefthook if you want one fast binary with no runtime dependency, and pre-commit if your team is Python-heavy or wants a large catalog of ready-made hooks.

Why do hooks work on my machine but not on a teammate's?

The symptom is boring and easy to miss: a teammate pushes code that your pre-commit lint would have rejected, and nobody sees an error, because nothing ran. There is no failure to find.

Git only executes hooks from the directory in core.hooksPath , which defaults to .git/hooks . That directory is inside .git , so it is not part of the repository content. Anything you put there stays on your machine.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.