From subversion to git (part3 – gitosis)
In order to have proper permission management with git you will have to install gitosis. Unfortunately there is no Debian package for it yet. For convenience you can download my build here. But building the package yourself is easy as the sources are already debianized.
sudo apt-get install build-essential fakeroot git clone git://eagain.net/gitosis.git cd gitosis.git ./debian/rules generate dpkg-checkbuilddeps
Of course you will have to install the packages checkbuilddeps has found missing. Once it’s satisfied you can build the package and install it.
dpkg-buildpackage -us -uc -rfakeroot sudo dpkg -i gitosis_0.2_all.deb
Note: The dependencies will require your system to be sort of up-to-date. It basically gave me a reason to upgrade from Edgy to Gutsy.
What’s left to do is to configure gitosis. Assuming you already have a public ssh key on your machine you can use that to initalize the repository.
$ scp .ssh/id_dsa.pub you@yourserver.com:/tmp $ sudo -H -u git gitosis-init < /tmp/id_dsa.pub Initialized empty Git repository in ./ Initialized empty Git repository in ./ $ rm /tmp/id_dsa.pub
Then you will have to checkout the gitosis admin project
git clone git@yourserver.com:gitosis-admin.git cd gitosis-admin vi gitosis.conf
and adjust the configuration to your needs.
[gitosis] [repo testproject] gitweb = yes description = Project description owner = you@yourserver.com [group team] writable = testproject members = you@yourserver.com [group gitosis-admin] writable = gitosis-admin members = you@yourserver.com
Also check the keydir. It should include “you@yourserver.com.pub” and all members that are listed in your config. Don’t forget to git-add them. And then commit and push the configuration to the server.
git commit -a -m "Inital configuration" git push
Adding projects is easy now. Just add them through the gitosis-admin project. When you push the changes you will get a warning
WARNING:gitosis.gitweb.set_descriptions:Cannot find 'testproject' in '/home/git/repositories' WARNING:gitosis.gitweb.generate_projects_list:Cannot find 'testproject' in '/home/git/repositories'
Then initialize your project and push it out.
git init git add . git commit -m "initial import" git remote add origin git@yourserver.com:testproject.git git push --all
Thanks to Garry for the help in getting this up and running.