2011-09-01 31 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版本並嘗試。