2

My git hook does not seem to be working. Namely a commit-msg hook from gerrit.

The commit-msg hook exist in <repo>/.git/hooks/ and has proper syntax.

William Boman
  • 2,079
  • 5
  • 26
  • 39

2 Answers2

9

Make sure your hook files are executable. If you use i.e. curl to download hooks, make sure you chmod +x them.

$ pwd
<repo>/.git/hooks
$ chmod +x commit-msg

If you use scp to get your hooks, the flag -p might set proper modes for you.

William Boman
  • 2,079
  • 5
  • 26
  • 39
  • Setting the executable flag is mentioned in the Gerrit documentation. https://gerrit-review.googlesource.com/Documentation/user-changeid.html – David Pursehouse Oct 06 '14 at 05:57
  • Just adding +x might be not enough. In may case the hook wasn't working until I changed permissions to 755 like the rest of hooks. – grzegorz Apr 30 '20 at 13:28
0

Check this other answer. It could be that core.hooksPath has been set to another path than $GIT_DIR/hooks, making your hooks in that folder ignored.

Gabriel Furstenheim
  • 2,969
  • 30
  • 27