Hasty Briefsbeta

Bilingual

pre-commit hooks are fundamentally broken

a day ago
  • Pre-commit hooks run on the working tree, not the index, causing issues with staged changes.
  • They interfere with rebasing, especially interactive rebases, and can fail when files are missing.
  • They prevent saving work-in-progress commits and are not suitable for incomplete code.
  • Pre-commit hooks are often slow, unreliable, and implemented in broken ways.
  • The author recommends using pre-push hooks instead, which avoid most of these issues.
  • The only acceptable use for pre-commit hooks is to prevent committing credentials.
  • Tips for pre-push hooks: run on the index, be fast and quiet, and do not auto-install.