Can I achieve it so that after pulling a repo from github the hooks has existed in .git/hooks directory?
Asked
Active
Viewed 2,041 times
3
VonC
- 1,129,465
- 480
- 4,036
- 4,755
Pan Ruochen
- 1,790
- 6
- 20
- 31
1 Answers
3
Not directly, as that would represent a security risk (you don't know what those hook scripts are doing)
You can try and:
- version a file (or files) representing your hooks in your git repo
- version a
.gitattributedeclaring a content filter driver (smudgescript), which will trigger ongit checkout. - in that
smudgescript, copy those files into your.git/hooks
(image from "Customizing Git - Git Attributes", from "Pro Git book")
But even in that case, you would need to activate that smudge filter with a git config command first (which can be a global config, so done before cloning the repo)
git config --global filter.hooks.smudge 'script_to_copy_hooks'