我試圖設置一箇中央存儲庫,當它從我的本地計算機推送到時,它會自動推送到另一個存儲庫。我現在一直在谷歌搜索幾天,我已經嘗試了所有的命令組合,我可以找到沒有運氣。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
我得到呼應兩個命令沒有輸出。我認爲這不是一件好事,是嗎? – 2011-04-26 20:40:00