Hasty Briefsbeta

Bilingual

Pre-commit hooks are fundamentally broken

4 months ago
  • #development
  • #git
  • #pre-commit
  • Pre-commit hooks are fundamentally broken due to several issues.
  • They run on the working tree, not the index, missing staged changes.
  • Pre-commit hooks can fail during rebases, especially with merge conflicts or modified commits.
  • They may block commits due to unrelated formatting issues in existing files.
  • Pre-commit hooks don't handle branches without certain files or old versions of the hook.
  • Using `--no-verify` becomes necessary in many scenarios, undermining the hook's purpose.
  • Pre-push hooks are recommended as a better alternative, avoiding most of these issues.
  • Tips for writing pre-push hooks include running on the index, being fast and reliable, and staying quiet.
  • Avoid automatic setup of hooks; manual setup with clear documentation is preferred.