[英]git post-receive hook not running
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.
但是,post-receive 钩子没有运行。 Details:
细节:
-rwxr-xr-x
permissions-rwxr-xr-x
权限echo "Some text"
before and after the hook, but this is not shown (see: Post Commit Hook Not Running ).echo "Some text"
,但这没有显示(请参阅: Post Commit Hook Not Running )。 . .
user@server:/home/repos/project1/hooks# cat post-receive
#!/bin/sh
echo "Hook is running..."
export GIT_WORK_TREE=/home/web/project1/www/
git checkout -f
rm -rf /home/web/project1/www/temp/
In order for a Git hook to run, it needs to have permissions set to allow it to be executable.为了让 Git 钩子运行,它需要设置权限以允许它是可执行的。 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: ...或者如果你想制作一个单一的钩子(例如
post-receive
)可执行文件:
chmod ug+x .git/hooks/post-receive
I had this problem.我有这个问题。 I had a typo in my script filename.
我的脚本文件名中有一个错字。
post-recieve instead of post-receive后接收而不是后接收
The issue was related to the mounting of the filesystem.该问题与文件系统的安装有关。 The partition was mounted as
noexec
, and therefore no files could be executed.该分区已挂载为
noexec
,因此无法执行任何文件。 This caused the hook not to run.这导致钩子无法运行。 I removed the
noexec
flag and it now works just fine.我删除了
noexec
标志,现在它可以正常工作了。
Seems GIT will NOT run the post-receive hook if there are no changes to the code base.如果代码库没有变化,似乎 GIT 不会运行post-receive钩子。
In my case,就我而言,
The post hook was not getting executed, but the "push" operation kept returning the following message. post 钩子没有被执行,但“推送”操作不断返回以下消息。
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.
在其上执行post-receive钩子。
I used MacBook and this helped in my situation:我使用了 MacBook,这对我的情况有所帮助:
chmod ug+x .husky/*
chmod ug+x .git/hooks/*
I had the same problem on a Centos 6 system, where it turned out that SELinux prevented hooks scripts from running.我在 Centos 6 系统上遇到了同样的问题,结果是 SELinux 阻止了钩子脚本的运行。 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):
将httpd_git_script_t转换为一个许可域在这里有帮助(因为“sesearch -A -s httpd_git_script_t -p exec”没有产生任何结果,即没有允许在 httpd_git_script_t 域中运行的进程具有 exec 权限):
semanage permissive -a httpd_git_script_t
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.
我的猜测是在执行 ssh 会话时没有为您的 ssh 会话设置标准输出,因此您永远不会看到回声的输出。 The link suggests testing it locally, not via ssh.
该链接建议在本地进行测试,而不是通过 ssh。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.