Aug 28 2009

Private git repositories on Site5

Category: tutorialgiordano scalzo @ 4:51 pm

It happens I have a shared host on Site5 and it happens most of kool koders are moving to git.
I’m not a so kool koder, but I think git deserve a try.

I know Github offers a wonderful service for open source projects, and I tried it for a bunch of pet works, but something is better to keep private, so, some month ago, I tried to set up a git repository on my Site5 account without success.

Some day ago, I bumped into a couple of posts and, finally, I reached my goal.

Set up a password-less connection

git communication is based on ssh, but a password request each ‘git push’ or ‘git pull’ can be annoying in day-by-day working, so the first thing is to make our connection trusted by the server.
In this post, we can find detailed instructions for a Linux system:

user@localhost:~$ ssh-keygen -t dsa
user@localhost:~$ scp ~/.ssh/id_dsa.pub remoteuser@remotehost:
user@localhost:~$ ssh remoteuser@remotehost:
[remoteuser@remotehost ~]$ cat id_dsa.pub >> .ssh/authorized_keys

For other OS, Google is your friend.

Create a repository on Site5

Some month ago, all Site5’s servers migrated to the last version of git , but if you can’t find it installed, you can open a ticket: Site5’s support is always friendly and quick.
Now we can create our repository:

[remoteuser@remotehost ~]$ mkdir -p git/repo.git
[remoteuser@remotehost ~]$ cd git/repo.git
[remoteuser@remotehost ~]$ git --bare init
[remoteuser@remotehost ~]$ exit

and create our local repository:

user@host:~$ mkdir git
user@host:~$ cd git
user@host:~$ git clone ssh://remoteuser@remotehost/~/git/repo.git

user@host:~$ echo 'Here we go' > README
user@host:~$ git add .
user@host:~$ git commit
user@host:~$ git push

Fixing “fatal: no matching remote head”-error

After that, when I tried to push my modifies I got an “fatal: no matching remote head” error… fortunately I wasn’t alone with that problem.
First of all we need create an empty local repository then tell git that the “origin” of the local repository is the remote repository

user@host:~$ cd repo
user@host:~$ git init
user@host:~$ echo 'Here we go' > README
user@host:~$ git add .
user@host:~$ git commit -ma ''
user@host:~$ git push
user@host:~$ git remote add origin ssh://remotehost/~/git/repo.git

Then we have to connect the upstream “origin” with the current local branch:

vi .git/config

and adding the following at the bottom:

[branch "master"]
  remote = origin
  merge = refs/heads/master

Finally we have to synchronize remote with local repository:

git push origin master

After that

git push

and

git pull

should work without problem

Conclusion

When discovered all necessary steps, any new repository installation goes smooth; in this post I tried to be complete and gather all the necessary informations.
If you are new to git in this page you will find some useful links.

Technorati Tags: , , ,

Tags: , , ,

2 Responses to “Private git repositories on Site5”

  1. Stephen Orth says:

    Thanks much for the post. I too have a Site5 account and I’ve been toying with the idea of setting up my own private git repo there… you have made it very easy with this post.

  2. giordano scalzo says:

    I’m very happy this post made your setup easy: I had the same problem and this is the kind of post I would make it as easy as point

Leave a Reply