2011-09-01 28 views
6

是否有任何方式,以使在GIT中钩回波GIT中钩:使能回声命令

/var/git/repositories/project.git/hooks/post-update 

#!/bin/bash 
unset GIT_DIR; 
echo '========post-update hook=========' 

cd /var/project; 
git reset --hard; 
git checkout testing; 
git pull; 
chmod -R 774 ./lib 

update-apps 
上的另一mashine

期望的git推输出:

#git push 
... 
Writing objects: 100% (10/10), 5.98 KiB, done. 
Total 10 (delta 3), reused 8 (delta 1) 
========post-update hook========= 
cd /var/project 
git reset --hard 
git checkout testing 
git pull 
chmod -R 774 ./lib 
update-apps 

这仅仅是一个例子,实际的命令链可能更复杂

和失败的地方

我应该将stdout莫名其妙地?

UPDATE

目前我有正常git push输出,然后========post-update hook========= ......并没有什么

哦! git版本是1.5.6.5

+1

但是当你尝试时,你的实际输出是什么? –

+1

检查钩子是否可执行(chmod + x) – sehe

回答

3

应该转发stdout或stderr上的所有输出。预计可用于所有pre-receive,update,post-receivepost-update挂钩。通过bourne shell中的set -x启用回声命令。

+0

set -x:修复了我的问题,谢谢 – jonny

2

githooks从手册:

标准输出和标准错误输出被转发到的git在另一端 发送包,所以可以为 用户只需回声消息。

但是在Git的某些早期版本以及智能HTTP的早期版本中存在一个已知问题,即未发送输出。更新你的git版本并尝试。