This is an archive of blog post I wrote during my first venture (beginning of 8thcolor).
We've started to prototype some of our ideas those last weeks. Currently, we're working on 3 projects. For one, we have 2 branches. Today, it exists wonderful tools to manage collaboration and revision of source code. Even when I'm alone in a software development project, I use one. It is about time to set up one for enkio.
The purpose of the current post is not to deal with the trollable question "which RCS is the best". Maybe I'll share later about that, but not now. We have chosen Git because it is used by the RoR and Django communities and dedicated hosting solutions, and we want make our opinion by ourselves.
This howto concerns the installation of Git and Gitosis. The last one is a simple manager of repository access using SSH key and not needing shell accounts. Before starting, here are some conventions I'll use for prompt symbols:
> = remote $ = local
As usual, update your package db:
> aptitude update
Install git and gitosis
> aptitude install git-core gitosis
The Debian package has created a
gitosis sys user and its home directory is at
Now, you need to setup gitosis and the administration access. To do that you need a SSH public key that I simply name
id.pub here. First of all, copy this key on the server in the
$ scp id.pub your.server.com:/tmp
You can now setup gitosis:
> su gitosis > cd > gitosis-init < /tmp/id.pub Initialized empty Git repository in /srv/gitosis/repositories/gitosis-admin.git/ Reinitialized existing Git repository in /srv/gitosis/repositories/gitosis-admin.git
This creates the repository gitosis-admin, setting up gitosis. But to effectively set up gitosis you have to clone it locally, in order to work on its setup file
gitosis.conf and add new SSH public keys for other users.
Retrieve gitosis-admin locally🔗
But before don't forget to correctly setup your SSH by adding at least the following in your
$ cat << EOF > ~/.ssh/config Host your.server.com IdentityFile ~/.ssh/id EOF
Now you can clone the gitosis-admin repository:
$ git clone firstname.lastname@example.org:gitosis-admin.git Cloning into gitosis-admin... Enter passphrase for key '/home/you/.ssh/id': remote: Counting objects: 5, done. remote: Compressing objects: 100% (4/4), done. remote: Total 5 (delta 0), reused 5 (delta 0) Receiving objects: 100% (5/5), done.
In the directory
gitosis-admin, you'll find the
gitosis.conf file and the directory
keydir where you have to put git user SSH public keys.
$ ls gitosis-admin gitosis.conf keydir $ ls gitosis-admin/keydir id.pub
Let's take a look into
$ cd gitosis-admin $ cat gitosis.conf [gitosis] [group gitosis-admin] writable = gitosis-admin members = id
gitosis-admin is already set up. It gives write access to the
gitosis-admin repository and there is a member:
id is the user name associated to the SSH public key defined inside the file
Setup access to the new repository🔗
To illustrate how to use and setup gitosis, I'll create a repository and give write access to another user. First of all, I have to set up the access:
$ cat << EOF >> gitosis.conf [group myteam] writable = myproject members = id another EOF
By adding those lines, all members of group
myteam have been given write access to
myproject. And members of this group are
another. I do not forget to add a SSH public key for another user:
$ cp ~/another.pub keydir/ $ git add gitosis.conf keydir/another.pub $ git commit -m "give write access to group myteam on project myproject" $ git push
And it's done.
Create the new repository🔗
Then, I can create a blank repository
$ cd .. $ git clone email@example.com:myproject.git Cloning into myproject... Enter passphrase for key '/home/id/.ssh/id': Initialized empty Git repository in /srv/gitosis/repositories/myproject.git/ warning: You appear to have cloned an empty repository.
Subscribe to the blog!