Unix
如何在 Unix 中設置公共 Git 儲存庫
我已經設置了許多私人儲存庫,我通過 SSH 送出,但我在設置公共儲存庫時遇到了問題。這是我到目前為止所做的:
通過 ssh 登錄我的伺服器
$ cd public_html/repos/ $ mkdir test $ cd test $ git --bare init $ touch git-daemon-export-ok # tell GIT it's ok to export this project $ chmod 777 -R ../test #making sure the directory had full read write execute permissions $ exit # exit out of ssh $ mkdir test_porject $ cd test_project $ touch README.txt $ git init #Initialized empty Git repository in ~/test_porject $ git add . $ git commit -m "initial commit" $ git remote add origin http://repos.mydomain.com/test $ git push origin master
這是我得到的錯誤:錯誤:請求的 URL 返回錯誤:500 訪問http://repos.mydomain.com/test/info/refs時 致命:HTTP 請求失敗
啊????不知道為什麼這不起作用。如果你去http://repos.mydomain.com/我沒有得到任何錯誤。任何幫助將非常感激。
我懷疑您上面的成績單實際上並不代表您輸入的實際命令。以下是設置 http 可訪問儲存庫的方法,這裡的命令(和輸出)正是我輸入的內容:
創建儲存庫:
$ mkdir -p public_html/git $ cd public_html/git $ git init --bare testrepo.git Initialized empty Git repository in /home/lars/public_html/git/testrepo.git/ $ cd testrepo.git $ mv hooks/post-update.sample hooks/post-update $ chmod 755 hooks/post-update
用一些送出填充它:
$ cd ~/tmp/ $ mkdir testrepo $ cd testrepo $ git init Initialized empty Git repository in /home/lars/tmp/testrepo/.git/ $ echo this is a test > myfile $ git add myfile $ git ci -m 'added myfile' [master (root-commit) eea6564] added myfile 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 myfile $ git remote add origin ~/public_html/git/testrepo.git $ git push origin master Counting objects: 3, done. Writing objects: 100% (3/3), 233 bytes, done. Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. To /home/lars/public_html/git/testrepo.git/ * [new branch] master -> master
通過http複製它:
$ cd ~/tmp $ git clone http://localhost/~lars/git/testrepo.git testrepo-cloned Cloning into testrepo... $ ls -A testrepo-cloned/ .git myfile
如果您執行此操作但它不起作用,我強烈懷疑您的網路伺服器配置存在問題。