Migrating from Gitosis to Gitolite on Ubuntu 12.04

Thursday, May 24, 2012 Posted by Suresh Payankannur 0 comments
Ubuntu 12.04 (Precise Pangolin) removed the support for Gitosis Git server. I have been using to host my projects locally. This forced me to look for alternatives. This link http://askubuntu.com/questions/126097/ubuntu-12-04-gitosis-no-longer-available discusses the alternatives.

I decided to go ahead and use Gitolite, which also provides migration from Gitosis. Here are the steps to migrate from Gitosis to Gitolite.

git-server: Where the git repository is hosted
git-client: A windows git client. I am using command line git from Cygwin
gitadmin: The user account under which the git repository is managed.
gituser: The windows user name under which the git client operations are performed.

Copy the existing public key to the server.
git-client> scp /home/gituser/.ssh/id_rsa.pub gitadmin@git-server:/tmp/  
Disable the gitosis and install gitolite
git-server> sudo apt-get install gitolite
git-server> su gitadmin
git-server> cd /home/gitadmin
git-server> mv .ssh/autorized_keys .ssh/autorized_keys.back
git-server> cp -r respositories repositories.gitosis
git-server> cd repsitories/gitosis-admin.git/hooks
git-server> mv post-update post-update.sample
git-server> cd /tmp
git-server> gl-setup id_rsa.pub
Make changes to the gitolite configurations
git-client> git clone git://github.com/sitaramc/gitolite
git-client> git clone gitadmin@git-server:gitolite-admin.git
git-client> gitolite/convert-gitosis-conf < gitosis-admin/gitosis.conf >> gitolite-admin/conf/gitolite.conf
git-client> cd gitolite-admin/conf
git-client> vi gitolite.conf
Modify the gitolite.conf and delete the gitosis-admin repo. Also modify any user names which do not have a dot '.' in them as discussed in the migration document here: http://sitaramc.github.com/gitolite/gsmigr.html. In my setup, the sample configuration will look like:



Copy the existing keys
git-client> gitosis-admin/keydir/*  gitolite-admin/keydir
Delete any duplicate keys as discussed here: http://sitaramc.github.com/gitolite/gsmigr.html

Commit the changes
git-client> cd gitolite-admin
git-client> git commit -am 'Moved to gitolite repository'
git-client> git push

Labels: ,

Installing a Git Server on Ubuntu 11.10

Tuesday, May 1, 2012 Posted by Suresh Payankannur 2 comments
Note: This will not work with Ubuntu 12.04, as the support for gitosis is removed in this release. See http://askubuntu.com/questions/126097/ubuntu-12-04-gitosis-no-longer-available for details. For migration from gitosis to gitolite, see this blog post: http://www.sureshpw.com/2012/05/migrating-from-gitosis-to-gitolite-on.html

There are a number of articles and blogs on how to use Git. But not very much information on how to setup your own Git server. Here are the steps on how to setup your Git server using gitosis on Ubuntu and use a Git client from Windows (cygwin in my case).

git-server: The server where the git repository is hosted.
git-client: The windows client accessing git
gituser: Windows user name using the git client
git: The username under which the git repository is created on the git-server.

First of all make sure that the Ubuntu server has the latest updates and install the required tools
git-server> sudo apt-get update
git-server> sudo apt-get dist-upgrade
git-server> sudo apt-get install python-setuptools
Install gitosis and add user named git on the git-server who will manage the git repository.
git-server> sudo apt-get install git-core gitosis
git-server> sudo adduser --system --shell /bin/sh --gecos 'git version control' \
                         --group --disabled-password --home /home/git git            
On the client machine, create a SSH public/private key for the user to access Git. Then provide permissions on the git server for this user.
git-client> ssh-keygen -t rsa
This will create private/public keys under $HOME/.ssh directory. On a cygwin platform, it will be under /home/gituser directory. Now upload the public key to git-server.
git-client> scp /home/gituser/.ssh/id_rsa.pub gitadmin@git-server:/tmp/
Initialize gitosis admin repository
git-server> sudo -H -u git gitosis-init < /tmp/id_rsa.pub
git-server> sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
Add your new project to git by modifying the git-admin configuration.
git-client> git clone git@git-server:gitosis-admin.git
git-client> cd gitosis-admin
git-client> vi gitosis.conf
The gitosis.conf has one project, gitosis-admin. Duplicate the [gitosis-admin] section and modify for your new project. The results will be as given below:



Commit and push the new changes to gitosis.conf file.
git-client> git commit -a -m 'Added new project my-new-project'
git-client> push
Import files to the new project
git-client> cd my-new-project
git-client:~/my-new-project/> git init
git-client:~/my-new-project/> git add .
git-client:~/my-new-project/> git commit -m 'Initial import of files to my-new-project'
git-client:~/my-new-project/> git remote add origin git@git-server:my-new-project.git
git-client:~/my-new-project/> git push -u origin master
Now the project is available in the remote git repository. Any new user can get the code by simply cloning the repository
git clone git@git-server:my-new-project.git

References

  1. http://www.hackido.com/2010/01/installing-git-on-server-ubuntu-or.html
  2. http://blog.jasonmeridth.com/2010/05/22/gitosis-and-gitweb-part-1.html
  3. http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push/
  4. https://help.ubuntu.com/community/Git

Labels: ,