I'm of the opinion that Git hooks are personal. That's why they're not part of the source code itself. I make extensive use of hooks, but they're tailored to my needs.
Note that you can skip hooks by passing the --no-verify flag to subcommands. Comes in handy when they're slow and you know that you've just fixed the wrong formatting that the previous invocation of your pre-commit hook complained about.
Can't stand pre-commit hooks. I want zero delay on commits. Checks can be run against pull requests in a GitHub action runner; no reason to force me to run them on my machine.
The main thing I've used them for is to prevent me committing to 'main', as we do everything via Merge Requests.
But it requires me to remember to set that up for each repo, and this is a massive pain. I'd like to be able to have a "clone with hooks" option, but I don't think anyone has found a way of making that work well without leaving people in danger when they clone a random repo.
I use git hooks in professional setting to prefix every commit message with the ticket the commit belongs to (this is done by extrapolating the ticket id from the feature branch name). It works pretty well and has saved my bacon a couple of times when I needed to figure out the provenance of a particular commit. Especially useful when I had to ask why that particular change was necessary.
6 comments
[ 0.14 ms ] story [ 33.5 ms ] threadNote that you can skip hooks by passing the --no-verify flag to subcommands. Comes in handy when they're slow and you know that you've just fixed the wrong formatting that the previous invocation of your pre-commit hook complained about.
But it requires me to remember to set that up for each repo, and this is a massive pain. I'd like to be able to have a "clone with hooks" option, but I don't think anyone has found a way of making that work well without leaving people in danger when they clone a random repo.