问题
I have a problem with configuration tslint and pre-commit hook. The point is that i created tsconfig file which work's well. And added bash script which not allow me to commit if tslint return any bugs. Problme is that i need commit this hook file for other people in my team. This should automatly replace pre-commit hook from .git folder. I just found a bash script which check my hooks in 'hooks' folder and replace them in .git folder. How can I commit this and make this 'automatically' for my team?
回答1:
"Committing a hook" is not possible for security reasons. If you could, then someone just cloning your repo and running basic operations could get arbitrary code executed on their machines.
Two common ways to deal with this are:
Document what people have to do to get the hook operational in their repository.
Automate what people have to do to get it. For example, in a project using a Makefile, I have this in the Makefile and people can just run
make setup-pre-push-hook
to get the hook to run "make check" whenever they push:
setup-pre-push-hook: setup-pre-push-hook-file grep -q 'make check' .git/hooks/pre-push || \ printf '\n%s\n\n' 'make check' >> .git/hooks/pre-push setup-pre-push-hook-file: test -f .git/hooks/pre-push || echo '#!/bin/sh' >.git/hooks/pre-push test -x .git/hooks/pre-push || chmod +x .git/hooks/pre-push
来源:https://stackoverflow.com/questions/50836112/commit-git-hook-to-repo