简体   繁体   English

git post-receive hook 没有运行

[英]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:细节:

  • Using SSH as protocol使用 SSH 作为协议
  • I have renamed the standard "post-receive.sample" to "post-receive"我已将标准“post-receive.sample”重命名为“post-receive”
  • This file has -rwxr-xr-x permissions该文件具有-rwxr-xr-x权限
  • The file is owned by the same user that owns the repo, which is the same SSH user that logs in and pushes该文件由拥有 repo 的同一用户拥有,即登录和推送的同一 SSH 用户
  • The actual pushing goes fine;实际的推动很顺利; files are updated - it's just the hook that does not run文件已更新 - 只是未运行的钩子
  • I tried putting 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 )。
  • Hook script is included below, although this appears not to be causing the problem钩子脚本包含在下面,虽然这似乎不会导致问题
  • Using git 1.7.0.4 on Ubuntu 10.04在 Ubuntu 10.04 上使用 git 1.7.0.4

. .

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

(Thanks to this post ) (感谢这篇文章

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM