Introduction and package installationIn this howto we'll not be covering the basic concept and usage of the Git VCS but just the installation procedure on Ubuntu 10.10.
Let's start installing the needed packages:
This will install all the packages and create the gitosis user.
sudo apt-get install git-core gitosis
Public key and initial configurationTo work with gitosis you need to setup a public key of a remote account that connects to the server via ssh to the server gitosis user.
If you don't already have somewhere on the server the public key you need to generate it on your local machine:
and then copy it to the remote host:
ssh-keygen -t dsa
at this point we can initialize gitosis with the key (on the remote server):
scp ~/.ssh/id_dsa.pub email@example.com:
You should get an output similar to this one:
sudo -H -u gitosis gitosis-init < id_dsa.pub
Initialized empty Git repository in /srv/gitosis/repositories/gitosis-admin.git/ Reinitialized existing Git repository in /srv/gitosis/repositories/gitosis-admin.git/
Cloning the gitosis-admin and adding a new projectWe can now clone the gitosis-admin repository to our local box:
You should now have a local clone of the repository on your box, working with the configuration files in gitosis-admin you can add new projects, users, etc.
cd ~ git clone firstname.lastname@example.org:gitosis-admin.git
Inside the gitosis repository you'll find a folder called "keydir" with a copy of your inital imported key: you'll have to place all additional keys for additional users inside the directory with the ".pub" extensions.
We can now edit the configuration file to add users and projects:
to make it look like this:
When you're satisfied with your configuration just commit and push the changes:
[gitosis] # # users (we made a group because every user could have more public keys for multiple PC) # [group user1] members = user1@box1 [group user2] members = user2@box1 user2@box2 # # repository for gitosis (insert only administrative users) # [group gitosis-admin] writable = gitosis-admin members = @user1 # # group of users to make up a team # [group team-name] members = @user1 @user2 # # first repository with a team working on it # [group projectname] members = @team-name writable = folder-name \ second-folder
git add . git commit -a -m "Added initial projects configurations" git push
Setting up repositories in a folder structureIf you want to setup a lot of repositories and want to subdivide them logically in a folder structure you'll to create those folder manually:
of course the gitosis.conf should refer with the writable parameter to the right path.
sudo mkdir /srv/gitosis/repositories/project sudo chown gitosis.gitosis /srv/gitosis/repositories/project
First PushNow that we have set up gitosis with the right keys and permission, let's create the first project by doing a first push from your local box:
# move to the folder containing the project you want to insert on git cd testproject # this will create the project git init # add all the files git add . # do a local commit git commit -a -m "Initial import" # add the remote repository git remote add origin email@example.com:optional-folder/testproject.git # push everything to the remote server git push origin master