Git post-receive hook not working

柔情痞子 提交于 2019-11-30 09:35:12
msquared

Please check whether your file has executable rights. Otherwise it can not be executed. Something like rwxr-xr-x should be sufficient.

You can add the missing bit with

$ chmod +x /path/to/post-receive

What transport method are you using to push to the repo?

Hooks are only executed when using 'smart' transport protocols like ssh and the cgi implementation of http. For other 'dumb' transport protocols like ftp, rsync, and the older http implementation, hooks will never be executed. I assume the git protocol would execute hooks but pushing over that protocol has never been considered a good idea.

All of these answers are useful, but it turns out I needed the "bin" directory of git in my PATH variable. I had the "cmd" directory only. Added c:\my_path_to_git\git\bin to PATH and it works fine. I found this answer by trial and error and looking at the apache error log. Thank you all for your help!

Try using full path to curl in post-receive file, as PATH can be different than when running script by hand.

If you want to see what is the environment of running post-receive script:

#!/bin/sh
export > file

or just (it will show env. variables after pushing into repo)

#!/bin/sh
export

Also, I'm not sure how executing shell scrips works on windows, so #!/path/to/installed/sh instead of #!/bin/sh might help

I think the simple answer is you need to move the contents of the post-receive hook server side instead of client side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!