Monday, March 5, 2012

Problem cloning local git repository using `git clone file:///…`

So I was trying to clone a local git repository using:
$ git clone file:///home/git/repositories/bar.git
And I would get output like this:
$ git clone file:///home/git/repositories/bar.git/ bar
Initialized empty Git repository in /home/brad/bar/.git
remote: Counting objects: 1317, done.
remote: Compressing objects: 100% (1179/1179), done.
remote: Total 1317 (delta 601), reused 406 (delta 57)
Receiving objects: 100% (1317/1317), 5.37 MiB | 683 KiB/s, done.
Resolving deltas: 100% (601/601), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
The issue was that although I had added myself to the git group, the permissions on the heads refs did not permit group read:
$ ls -lha /home/git/repositories/bar.git/refs/heads
total 12K
drwx------ 2 git git 4.0K 2012-03-05 15:42 .
drwx------ 4 git git 4.0K 2012-02-28 14:21 ..
-rw------- 1 git git   41 2012-03-05 15:45 development
-rw------- 1 git git   41 2012-03-05 15:42 master
Simple fix:
$ chmod g+r /home/git/repositories/bar.git/refs/heads/*
So why was this suddenly a problem?

It just so happens I recently upgraded from gitosis to gitolite, and gitolite uses a different umask (0077) to gitosis. This means that every new file created was created with only user permissions.

I want g+rx, so I edited /home/git/.gitolite.rc and changed $REPO_UMASK to 0027.

No comments:

Post a Comment