header

Torsten Curdt’s weblog

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.

  • I would check with the folks on IRC. Especially as you are on windows I have no clue.
  • Gitmanage
    Hi I am getting the below error when itried to clone my gitosis-admin.git
    Initialized empty Git repository in e:/gitosis-admin/.git/
    DEBUG:gitosis.serve.main:Got command "git-upload-pack '/home/git/repositories/gi
    tosis-admin.git'"
    DEBUG:gitosis.access.haveAccess:Access check for 'AshwathKASHWATH' as 'writable'
    on 'home/git/repositories/gitosis-admin.git'...
    DEBUG:gitosis.access.haveAccess:Stripping .git suffix from 'home/git/repositorie
    s/gitosis-admin.git', new value 'home/git/repositories/gitosis-admin'
    DEBUG:gitosis.group.getMembership:found 'AshwathKASHWATH' in 'gitosis-admin'
    DEBUG:gitosis.access.haveAccess:Access check for 'AshwathKASHWATH' as 'writeable
    ' on 'home/git/repositories/gitosis-admin.git'...
    DEBUG:gitosis.access.haveAccess:Stripping .git suffix from 'home/git/repositorie
    s/gitosis-admin.git', new value 'home/git/repositories/gitosis-admin'
    DEBUG:gitosis.group.getMembership:found 'AshwathKASHWATH' in 'gitosis-admin'
    DEBUG:gitosis.access.haveAccess:Access check for 'AshwathKASHWATH' as 'readonly'
    on 'home/git/repositories/gitosis-admin.git'...
    DEBUG:gitosis.access.haveAccess:Stripping .git suffix from 'home/git/repositorie
    s/gitosis-admin.git', new value 'home/git/repositories/gitosis-admin'
    DEBUG:gitosis.group.getMembership:found 'AshwathKASHWATH' in 'gitosis-admin'
    ERROR:gitosis.serve.main:Repository read access denied
    fatal: The remote end hung up unexpectedly

    Can you tell me what may be the issue
  • Elvis
    @tcurdt

    I can push my new repo to server with luck finally. I revise the new created repo ownership to gituser on my server. And then I can git push with luck.
  • Elvis
    @tcurdt

    I can push by creating a new repo on server and typing the correct repo path. But another error occurs when I was pushing

    error: unable to create temporary sha1 filename ./objects/46: Permission denied

    fatal: failed to write object
    error: unpack failed: unpacker exited with error code
    To gitter@192.168.1.22:~gitter/repositories/newrepo.git
    ! [remote rejected] master -> master (n/a (unpacker error))
    error: failed to push some refs to 'gitter@192.168.1.22:~gitter/repositories/newrepo.git'

    Have u ever encountered this issue??
  • @Elvis: I might have missed out on one step.

    Just create the a bare repository where it is supposed to be on the server with "git init --bare". Let me know if that fixed it.
  • Elvis
    I write my steps, can u help to point out where i'm wrong?

    After I clone gitosis-admin.git from server

    1. First I edit gitosis.conf and add
    [group testrepo]
    writable = testrepo
    members = git-testing

    2. mkdir testrepo under directory gitosis-admin-git
    3. cd testrepo and then git init-db
    4. touch readme and then git add readme
    5. git commit -a -m "initial import"
    6. git remote add origin git@my.server.name:testrepo.git
    7. git push --all (git push origin master)

    Result : fatal: 'testrepo.git': unable to chdir or not a git archive
    fatal: The remote end hung up unexpectedly

    p.s : In step 7 ":testrepo.git" should I list the specified path? example ":/home/user/gitosis-admin.git/android.git".
  • Elvis
    I did the final push for my new created project to server. It always show me that newproject.git unable to chdir or not a git archive.

    Any hint for me, I've been bothering on this issue for days!! Thanks!!

    BTW, set gitosis.conf correctly is required before init and then push a new project??
  • Justin S. Leitgeb
    apt-get install cdbs also seems to be a dependency that you didn't mention, at least on my machine. Thanks for the helpful guide!
  • I like your last line "git push --all". I was using a more complicated version indicated in the gitosis README (that I found hard to remember). Now I'll keep in mind '--all' :)
blog comments powered by Disqus