Git:将现有存储库放在共享服务器上

时间:2014-08-22 13:26:12

标签: git

我尝试按照官方git文档中的说明将现有存储库放在共享服务器上。但是当我尝试在服务器上克隆存储库时,我收到一个错误。谁能看到我哪里出错了?感谢。

[在本地计算机上]

mkdir temp
cd temp
vim test.txt
[insert]some text
[escape]:wq
git init
git add *.*
git commit -m 'First commit.'
cd ..
scp -r temp user@12.345.67.890:/home/user

[在服务器上]

git clone --bare --shared temp temp.git
> Initialized empty Git repository in /home/user/temp.git/
rm -rf temp // if I don't delete temp I don't get an error, but it doesn't make sense to leave it there

[在本地计算机上]

git clone ssh://user@12.345.67.890:/home/user/temp.git temp2
> Cloning into 'temp2'...
user@12.345.67.890's password:
> error: object directory /home/user/temp/.git/objects does not exist; check .git/ojects/info/alternates.
> fatal: git upload-pack: cannot find object b85fsdg87sg9sg877sg79s7g79sg7:
> fatal: Could not read from remote repository
> Please make sure you have the correct access rights and the repository exists.

1 个答案:

答案 0 :(得分:1)

这是一种有效的替代方法。我无法通过官方文档工作制作方法 - 我试了大约半天。

[在服务器上]

$ git init --bare --shared temp.git

[在本地]

$ cd temp
$ git remote add origin ssh://user@12.345.67.890:/home/user/temp.git
$ git push origin master

$ git clone ssh://user@12.345.67.890:/home/user/temp.git temp2