1

I've seen a lot of other questions here like this one, but the vast majority of them are related to permissions. So to clarify:

  • My file is called exactly "post-receive"
  • It has no extension
  • It is located in .git/hooks
  • It starts with "#!/bin/bash"
  • It has execution permissions

Running "ls -l post-receive" returns:

-rwxr-xr-x

If I run the file manually, through git bash, it works perfectly. But no matter what I push, it never triggers automatically. What's going on here?

kiryakov
  • 145
  • 1
  • 7
  • 2
    is that `.git/hooks/post-receive` file on the server or on your machine? `post-receive` is a **server side** hook – anthony sottile Sep 02 '21 at 12:46
  • @AnthonySottile How can the post-receive hook be on the server, if you can't commit githooks? .git folder is not part of the repository and that's where the githook is. – kiryakov Sep 02 '21 at 12:53
  • 3
    @peepeepoopoo `post-receive` is a server side hook! You [can](https://stackoverflow.com/q/427207/7976758) store hooks in the repository but you have to have access to `.git/hooks/` at the server. If the server is a Git hosting like Github/Gitlab then you cannot have server-side hooks but you can have webhooks. – phd Sep 02 '21 at 13:52
  • @phd Yeah, that was it. If you want you can make an answer so I can pick it. – kiryakov Sep 03 '21 at 06:56

1 Answers1

1

post-receive is a server side hook! You can store hooks in the repository but you have to have access to .git/hooks/ at the server. If the server is a Git hosting like Github/Gitlab then you cannot have server-side hooks but you can have webhooks.

phd
  • 82,685
  • 13
  • 120
  • 165