I'm trying to get the pre-push git hook to work. I can run it from git bash just fine, it just doesn't get picked up when I'm pushing. Am I doing something wrong?
File is ".git\hooks\pre-push"
File type is: Shell Script (.sh)
File contents:
#!/bin/sh
echo "*****Running pre-push******"
Results, when running from git bash:
$ ./pre-push.sh
*****Running pre-push******
CodePudding user response:
Two things:
Make sure pre-push doesn't have an extension. The file should just be called
pre-push
, with no.sh
at the end. Bash knows it's a shell script because of the '#!/bin/sh'.Configure the hooks path to be
.git/hooks
:git config core.hooksPath .git/hooks
Once you run this second step, everything should work like normal. You can also configure in globally to be .git/hooks
if you'd like.