git post-receive hook not running

后端 未结 6 1939
被撕碎了的回忆
被撕碎了的回忆 2020-12-25 12:23

I have a bare repo server-side, and I am able to successfully commit and push from my local machine. However, the post-receive hook is not running. Details:

  • Us
相关标签:
6条回答
  • 2020-12-25 12:37

    I had the same problem on a Centos 6 system, where it turned out that SELinux prevented hooks scripts from running. Turning httpd_git_script_t into a permissive domain helped here (since "sesearch -A -s httpd_git_script_t -p exec" yielded nothing, ie. no process running in the httpd_git_script_t domain was allowed exec permission):

    semanage permissive -a httpd_git_script_t
    
    0 讨论(0)
  • 2020-12-25 12:38

    The issue was related to the mounting of the filesystem. The partition was mounted as noexec, and therefore no files could be executed. This caused the hook not to run. I removed the noexec flag and it now works just fine.

    0 讨论(0)
  • 2020-12-25 12:55

    In order for a Git hook to run, it needs to have permissions set to allow it to be executable. If a hook doesn't seem to be running, check the permissions, and make sure it's executable. If it isn't you can make all hooks executable like this:

    chmod ug+x .git/hooks/*
    

    ...or if you want to make a single hook (eg. post-receive) executable:

    chmod ug+x .git/hooks/post-receive
    

    (Thanks to this post)

    0 讨论(0)
  • 2020-12-25 12:58

    Are you sure it's not running? It must be running, you just can't see it. My guess is that there is not stdout set to your ssh session at the time it's executed, so you won't ever see the output of your echo. The link suggests testing it locally, not via ssh.

    0 讨论(0)
  • 2020-12-25 13:00

    I had this problem. I had a typo in my script filename.

    post-recieve instead of post-receive

    0 讨论(0)
  • 2020-12-25 13:04

    Seems GIT will NOT run the post-receive hook if there are no changes to the code base.

    In my case,

    The post hook was not getting executed, but the "push" operation kept returning the following message.

    Everything up-to-date

    So I just created an empty file in my code, did commit and then pushed to remote. On which the post-receive hook got executed.

    0 讨论(0)
提交回复
热议问题