2011-04-26 107 views
1

我試圖設置一箇中央存儲庫,當它從我的本地計算機推送到時,它會自動推送到另一個存儲庫。我現在一直在谷歌搜索幾天,我已經嘗試了所有的命令組合,我可以找到沒有運氣。Git從更新後的掛鉤失敗 - X不是存儲庫

設置: 我首先創建了一個裸露的中央存儲庫,然後將其作爲非裸設備克隆到第二臺機器。我將第二臺機器添加爲第一臺機器,稱爲「www」。我確認我可以從第一臺機器手動執行「git push www master」,它會通過SSH更新第二臺機器。然後我通過HTTP將存儲庫克隆到我的本地開發機器。我可以從本地推到中央就好了。

我的post-update掛鉤以目前的形式:

#!/bin/bash 

cd /var/git_repos/site.git 

unset $(git rev-parse --local-env-vars) 

branch=$(git rev-parse --abbrev-ref HEAD) 

if [ "$branch" == "master" ]; 
then 
    echo "Pushing $branch to www..." 
    env -i git push www master 
fi 

exec git update-server-info 

我已經從不同的SO和博客拼湊起來這一點。從第一臺機器的CLI(「cd /var/git_repos/site.git/hooks; ./post-update」)手動執行時,它工作正常,但執行時會出現錯誤消息「www不是Git存儲庫」作爲一個鉤子。

輸出:

$ git push 
Password: 
Counting objects: 5, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (2/2), done. 
Writing objects: 100% (3/3), 264 bytes, done. 
Total 3 (delta 0), reused 0 (delta 0) 
remote: Pushing master to www... 
remote: fatal: 'www' does not appear to be a git repository 
remote: fatal: The remote end hung up unexpectedly 
To https://[email protected]/site.git 
    e3d3a1d..103c819 master -> master 

誰能告訴我什麼,我做錯了什麼?

編輯:我已經想通了,我最初的問題是,在site.git的權限並不完全正確設置。解決了這個問題後,我遇到了一個新問題。

新的輸出:

$ git push 
Password: 
Counting objects: 5, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (3/3), done. 
Writing objects: 100% (3/3), 332 bytes, done. 
Total 3 (delta 1), reused 0 (delta 0) 
remote: I am apache <---- Output of "whoami" for debugging 
remote: Pushing master to www... 
remote: ssh: connect to host 192.168.1.79 port 22: Permission denied 
remote: fatal: The remote end hung up unexpectedly 
To https://[email protected]/site.git 
    29d504c..f14f201 master -> master 

我曾嘗試加入以下到我的/ etc/sudoers文件沒有運氣文件:

apache ALL=NOPASSWD: /usr/bin/ssh 

回答

1

這是試圖推到時候你得到的錯誤未知的遠程。嘗試:

git push thisisprobablynotaremote master 

檢查

git remote -v 

,確保WWW定義正確,還要檢查

git config --list 

WWW應該有作爲。

從掛鉤本身打印所有命令的輸出並比較輸出。

+0

我得到呼應兩個命令沒有輸出。我認爲這不是一件好事,是嗎? – 2011-04-26 20:40:00

0

我會建議將www更改爲您推送到的遠程倉庫的完整URL。另外將master更改爲master:master可能會有所幫助。

+0

我奇怪地得到了「權限被拒絕」的錯誤。 – 2011-04-27 02:51:35

0

不要做

unset $(git rev-parse --local-env-vars) 

我想你看到人們試圖從不同的回購做一個git拉了鉤。你只是在執行與當前回購相關的所有命令。所以你不必這樣做。

同樣,不要做:

env -i git push www master 

刪除env -i

+0

我正在嘗試將這些命令作爲最後的努力,但刪除它們沒有任何區別。 – 2011-04-27 02:43:59