我尝试按照官方 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 [email protected]:/home/user
[在服务器上]
git clone --bare --shared temp temp.git
> Initialized empty Git repository in /home/user/temp.git/
[在本地机器上]
git clone ssh://[email protected]:/home/user/temp.git temp2
> Cloning into 'temp2'...
[email protected]'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
这是另一种可行的方法。我无法使官方文档中的方法奏效 - 我尝试了大约半天。
[在服务器上]
$ git init --bare --shared temp.git
[本地]
$ cd temp
$ git remote add origin ssh://[email protected]:/home/user/temp.git
$ git push origin master
$ git clone ssh://[email protected]:/home/user/temp.git temp2