News for hackers. Stuff that matters.
Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by AndrewDucker on Monday October 20, 2025 @03:12AM (#45640783)
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.

Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by indentit on Monday October 20, 2025 @03:22AM (#45640839)
Isn't that what branch policies are for? It can get annoying when making a release (from a local machine as opposed to automatically in CI/CD pipelines), but in other circumstances it serves the purpose very well in my experience
Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by AndrewDucker on Monday October 20, 2025 @03:36AM (#45640903)
Ooh, how do those work locally?

I've only encountered those on the server side.

Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by indentit on Monday October 20, 2025 @04:09AM (#45641114)
git itself has no concept of branch policies, it is purely a server side thing. But surely it doesn't really matter what branch you commit to locally, if you can't push it, you haven't done any damage and can just create a new branch and push that instead?
Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by AndrewDucker on Monday October 20, 2025 @04:23AM (#45641247)
Yes, but I'd like to avoid the "create a new branch, switch back to main, reset main back to origin, come back to the new branch" dance. And a git hook does that, but it's not trivial to set up (particularly when there are lots of repos).
Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by indentit on Monday October 20, 2025 @04:32AM (#45641300)
Maybe create a shell alias which would act as a wrapper around git to do just that, when you try to commit on the wrong branch
Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by hambes on Monday October 20, 2025 @11:03AM (#45644748)
read the article, it recommends devenv or pre-commit as tools that do thr setup for you
Re:Discussion of the Benefits and Drawbacks of the Git Pre-C... by AndrewDucker on Tuesday October 21, 2025 @11:22AM (#45656951)
Alas, neither works for me. I've not managed to find a Windows equivalent yet.

Edit: `git config --global core.hooksPath D:\GitHooks\` is what I needed!