I have created a Git repository on my Desktop machine (Windows 7) with:
git init git add <all my files> git commit -m "added my files"
Now I have installed a new Ubuntu Server 10.10 on a machine on my LAN and installed OpenSSH. My home directory is /home/jonas
and I created a directory ~/code/
to contain my projects. I can log in to the Ubuntu Server from Windows 7 with Putty.
I installed Git on the server with sudo apt-get install git
Now I want to add my Git repository on my Desktop to the Server. I tried to follow the instructions from Pragmatic Version Control Using Git.
From my Desktop I run these commands:
git remote add origin [email protected]/home/jonas/code/myproject.git git push origin master
But I got this error message:
fatal: '[email protected]/home/jonas/code/myproject.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly
What is the problem? How do I create the remote repository?
As PerfectlyNormal suggested, I added a :
in the address. Now it worked better, and I had to type my password to the server, but then I got a similar error message:
fatal: '/home/jonas/code/myproject.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly
Do I have to initialize a Git repository on the server before I can git push
to it?
To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. The git remote add command takes two arguments: A unique remote name, for example, “my_awesome_new_remote_repo” A remote URL, which you can find on the Source sub-tab of your Git repo.
git remote add origin [email protected]/home/jonas/code/myproject.git
When using SSH, remote repository addresses can be expressed in two ways. One using absolute paths and one using relative paths from the users home directory. You've mixed them up.
The corrected command would be one of the following.
git remote add origin [email protected]:code/myproject.git git remote add origin ssh://[email protected]/home/jonas/code/myproject.git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With