I've tried to follow the instructions from the official git documentation to put an existing repository on a shared server. But when I try to clone the repository on the server I get an error. Can anyone see where I'm going wrong? Thanks.

[On local machine]

mkdir temp

cd temp

vim test.txt

[insert]some text


git init

git add *.*

git commit -m 'First commit.'

cd ..

scp -r temp user@12.345.67.890:/home/user

[On server]

git clone --bare --shared temp temp.git

> Initialized empty Git repository in /home/user/temp.git/

[On local machine]

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.

Here is an alternative method that works. I could not make the method from the official documentation work - I tried for about half a day.

[On server]

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

[On local]

$ 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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy