After using svn for some years, I would like to try a “new” approach. So I decided to migrate my repos to git and install something like a git server using gitolite.
During the journey I was inspired by http://www.bigfastblog.com/gitolite-installation-step-by-step. There were also some interesting facts about how to work with git on http://rogerdudler.github.io/git-guide/index.de.html.
Doing as root on the server machine
I will use the root user on my server to manage gitolite. So I create the ssh key for my gitolite user in the .ssh directory of the root-user on my server. Afterwards it is an easy task to copy the key to another machine or give some other users the permissions to manage the gitolite-admin repo.
ssh-keygen -t rsa -f gitolite
--shell /bin/bash \
--gecos 'git version control' \
--home /home/gitolite gitolite
cp ~/.ssh/gitolite.pub /home/gitolite/
To let ssh know, that it has to use the right key when you work with git, just add the following to ~/.ssh/config:
Doing as gitolite user on the server machine
After creating the gitolite user, it’s time to install and configure gitolite.
git clone git://github.com/sitaramc/gitolite
gitolite/install -to /home/gitolite/bin
/home/gitolite/bin/gitolite setup -pk gitolite.pub
To configure your gitolite server, you have to checkout the gitolite-admin repo. While I created a key-pair called gitolite and configured ssh for my root-user to use the corresponding key when connecting to localhost, I am now able to clone the repo. This could be done as following:
git clone localhost:gitolite-admin
After doing so, you can add your users keys to gitolite-admin/keydir as <username>.pub and configure the repositories and their permissions in gitolite-admin/conf/gitolite.conf. After committing and pushing the repo back to the server, the config will be active.
Create a new repo inside the actual directory
Clone an existing repo locally
git clone <host>:<repo>
Push your version of the master branch into the repo
git push origin master
Add remote location to local repo
git remote add origin <host>:<repo>