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: , , ,


Aug 28 2009

Puts ‘Hello, world’

Category: megiordano scalzo @ 12:01 am

This is my first post in my last of a lot of unfinished blogs.

In that last one I’ll write mainly in english (a sort of) and about programming.

My goal is to reach a some form of continuity and to post 2 or 3 articles each week; I’ll check at the end of the year if I succeded or not.

As said before, english isn’t my first language, so, please, forgive and correct my bigger mistakes.

Technorati Tags: ,

Tags: ,