-
-
Save hraban/10c7f72ba6ec55247f2d to your computer and use it in GitHub Desktop.
@doronguttman I have looked into this but as far as I can tell there is no clean way of "adding" a hook. By setting a global hooksPath, you are locked in to that dir for all repos. You can override it locally, but now you lose all global hooks, and you're back to copy/pasting hook scripts from the template dir.
Conversely, if you have any existing repos with custom hooks, setting that global option will disable them.
The best approximation of "supplemental hooks" I've found is appending if [[ -x .git/hooks/pre-commit ]]; then exec ./git/hooks/pre-commit; fi
but it feels brittle.
Thanks for your reply @hraban, for me, the init.templatedir
just did not work π€·ββοΈ , but the core.hooksPath
solved the issue for me. Maybe others can use the init.templatedir
.
In any case, your work here is highly appreciated β€οΈ
Ah now I understand what you meant, you had a specific problem getting it to actually work at all. Interesting, are you on Windows? What do you think the problem could be? Just for completeness' sake: the templatedir only applies to new repositories, not to existing ones. Might that have been the problem.
Either way, it's a gist, all comments welcome :P it's 3 lines of bash--not exactly ffmpeg π
π indeed on windows (wsl debian), but I guess my issue was the misunderstanding of what templatedir
actually is. Indeed I was looking for it to work on an already cloned repo. I guess I had missed this comment π
well, maybe someone will find the core.hooksPath
comment useful π€·ββοΈ
why there is symbol d in regex ^[+d].*NOCOMMIT ? In which cases diff can return lines starting with d?
ok, thanks!
Thank you @hraban !
if this does not work (line #13), try
git config --global core.hooksPath "$HOME/.git_template/hooks"
instead