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フックが unsetであることを確認してください。GIT_DIRそうしないと、ライブ サイトの git リポジトリではなく、フックの git リポジトリが引き続き参照さ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ているファイルの 1 つにあるようです。上記のシェル スクリプトは、別のユーザーを使用して実行されました。HEADroot

于 2013-10-14T02:09:28.407 に答える