Thoughts and tutorials on programming

Saturday, August 01, 2009

how to setup a remote git repository using ssh

Finding the normal instructions slightly lacking on how to create a brand-new, empty git repository via SSH for a central location, here they are:


$ ssh myserver.com
Welcome to myserver.com!
$ mkdir /var/git/myapp.git && cd /var/git/myapp.git
$ git --bare init
Initialized empty Git repository in /var/git/myapp.git
$ exit
Bye!

Add the remote repository to your existing local git repo and push:

$ cd ~/Sites
$ mkdir myapp
$ git init
$ git remote add origin ssh://myserver.com/var/git/myapp.git
$ touch README
$ git add README
$ git commit -m "initial commit"
$ git push origin master

2 comments:

Roger Pack said...

this to overcome these errors when setting up git ssh

Warning: the RSA host key for 'thomasknoell.com' differs from the key for the IP address '66.246.138.39'
Offending key for IP in /home/packrd/.ssh/known_hosts:1311
Matching host key in /home/packrd/.ssh/known_hosts:1353
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://rdp@thomasknoell.com/home/rdp/svn_repo/bridal'

and

C:\dev\ruby>git clone ssh+git://rdp@thomasknoell.com/home/rdp/svn_repo/bridal
Initialized empty Git repository in /cygdrive/c/dev/ruby/bridal/.git/
Warning: the RSA host key for 'thomasknoell.com' differs from the key for the IP address '66.246.138.39'
Offending key for IP in /home/packrd/.ssh/known_hosts:1311
Matching host key in /home/packrd/.ssh/known_hosts:1353
fatal: no matching remote head

and
git fetch origin
C:\dev\ruby\bridal>fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

Virge said...

Thanks! This fixed my problem perfectly.

Contributors

Followers