After many months experiencing with SVN, we want to try to shoot with GIT.
We will use a great tool for manage our git repositories: gitosis.
aptitude install gitosis
sudo -H -u gitosis gitosis-init
where ssh_key.pub is a file that contains a public rsa key generated with ssh-keygen (as default is saved on ~/.ssh/id_rsa.pub).
The key is used to authenticate the repositories admin, so can even be on another host with ssh access.
Now on your local machine (even different where gitosis was installed, but you need the private rsa key on it):git clone gitosis@YOUR_SERVER_IP:gitosis-admin.git
This repository contains configuration data for gitosis, you will modify it, commit and push, and gitosis automatically reload itself.
Modify gitosis.conf:[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = scorp@antani
[group developers]
writable = sandbox
members = scorp@antani
The group gitosis-admin is the one that can manage the gitosis configuration (we are doing it now).
The group developers i've added it's the one with all developers will use to access our repositories. You can even create many different groups for many different repositories.
Sandbox is the name of a testing git repository i am going to create (not exists yet, i've only specified that the user scorp@antani can push commits into).
To render effetive changes, do:git commit -a -m "Allow scorp write access to sandbox"
git push
Now let's try the new toy, we should initialize the sandbox repository:mkdir sandbox
cd sandbox
git init
git remote add origin gitosis@YOUR_SERVER_IP:sandbox.git
touch helloworld.txt
git add helloworld.txt
git commit -m 'first test commit'
git push origin master:refs/heads/master
Happy now? Good Coding.
Common errors
~/sandbox$ git push origin master:refs/heads/master
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'gitosis@192.168.1.1:sandbox.git'
You should remember to commit changes before to push it ;)
References: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
Comments
Ankur
31/07/2009 19:17
Permalink
The latest Lenny gitosis uses
The latest Lenny gitosis uses gitosis user so need to do this:
git clone gitosis@YOUR_SERVER_IP:gitosis-admin.git
scorp
15/10/2009 14:44
Permalink
Are you sure? This doesn't
Are you sure? This doesn't apply to me, I should write gitosis@, without it pass my username, as standard ssh do.
Itz
03/12/2009 07:12
Permalink
Excelent, thanks for the
Excelent, thanks for the post.
Nightfly
12/02/2010 11:44
Permalink
"You should remember to
"You should remember to commit changes before to push it ;)"
Definitely. :S
Setting up Git ...
07/04/2010 15:47
Permalink
[...] —— Based on scie.nti.st
[...] —— Based on scie.nti.st and LiberLabs-Blog [...]
Add new comment