Published: Sun 07 November 2010
By idl0r
In misc .
tags: Technical English git gitolite gitosis migration
So we finally
migrated
successfully from gitosis to
gitolite . I'll try to explain
how to do it easily.
Client side, part 1:
Update your local gitosis-admin repository
Server side, part 1:
Disable write access to your gitroot by either changing the "git"
users homedir (I prefer this method) or by renaming the
~/.ssh/authorized_keys file. This is important to ensure gitolite
gets a clean authorized_keys file
Make a backup of your gitroot by using rsync, tar or whatever else..
Cleanup/Remove your old gitroot
Install gitolite
Copy the example gitolite.rc into the git users homedir (e.g.
~/.gitolite.rc) and set your settings (Don't forget to chown/chmod
it later)
Run "gl-setup /path/to/your/pubkey" as "git" user
Client side, part 2:
git clone git+ssh://git.yourdomain.tld/gitolite-admin.git
Grab
my convert.pl
script
cd /path/to/gitosis-admin
perl
~/convert.pl
[/path/to/your/gitosis.conf] >> /path/to/gitolite.conf
Commit & Push your changes but DON'T add your old keys from
keydir yet!
All repositories will be created after your push, ignore the pubkey
warnings for now.
Server side, part 2 (Run commands as user "git"):
Create a tmp directory and cd into it
git clone -q --bare /path/to/your/gitroot/backup/repository.git
cd repository.git
GL_BYPASS_UPDATE_HOOK=1 git push -q --mirror
/path/to/the/new/gitroot/repository.git
With clone and push --mirror we ensure that we don't keep any old hooks
or other stuff from gitosis.
In most cases it might be enough to simply remove the old hooks e.g. by
running "find /path/to/gitroot/ -type d -name hooks -exec rm -f {}/*
\;", then you could skip the server part 2 and use your old gitroot
instead.
I did part 2 to ensure we really have a clean new gitroot. So decide
yourself.
If you need to push via ssh, create a migration user in gitolite.conf
repo @all RW + = migration
and add the public key as well.
Then start a ssh-agent and ssh-add your public key. Now you don't need
to enter the passphrase for each push.
If you have a lot of repositories then just write a small shell script
including the git clone/push stuff.
Once you're done: Remove the migration user and its key.
Now add all your old gitosis keys to gitolite. That's it!
If you need the post-update hook from git (update-git-server-info) then
just link it into your ~/.gitolite/hooks/common dir.
ln - s / usr / share / git - core / templates / hooks / post - update . sample ~/ . gitolite / hooks / common / post - update
Run gl-setup again (as user "git") and you're done.
Each time when you modify your .gitolite.rc, add/change hooks or update
gitolite itself then simply run gl-setup. NOTE : Old hooks will not
be removed by gitolite/gl-setup!
Gentoo user can choose between the upstream/vanilla version
dev-vcs/gitolite or our own fork
dev-vcs/gitolite-gentoo .