3

Just like many, I am trying to create a post-receive hook on a server-side remote git. The following is my code:

cd [LIVE SITE DIR] && git pull origin master | wall

I have added the wall so that it can be broadcasted and I can receive the notice. One thing that I noticed is when I run ./post-receive, it all works fine.

Broadcast message from root (Tue Oct  8 14:58:13 2013):

Updating 7ebd925..1a25791
Fast-forward
 html/header.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

But, when I tried to do a git push , ./post-receive seems to be called but I received the following empty broadcast:

Broadcast message from root (Tue Oct  8 14:53:32 2013):

I have tried to include pwd, ls command into the post-receive and everything works fine for both situations. Except for the git pull that it seems to return an empty output.

Have gone through all the suggestions provided in SO but to no avail :(. Any help or suggestion is much appreciated.

Thanks!

4

2 回答 2

11

确保你的post-receive钩子未设置GIT_DIR,否则它仍然会引用钩子的 git repo,而不是你刚刚所在的实时站点的 git repo cd

cd [LIVE SITE DIR]
unset GIT_DIR
git pull

或者:

cd [LIVE SITE DIR]
env -i origin master

或者:

cd [LIVE SITE DIR]
git --git-dir=[LIVE SITE DIR]/.git pull
于 2013-10-08T08:29:05.180 回答
1

问题似乎是因为其中一个文件.git具有文件所有者。上面的 shell 脚本是使用另一个用户执行的。HEADroot

于 2013-10-14T02:09:28.407 回答