Setting Up Git Repositories on the Andrew File System

After having fun taking courses for over a month at CMU, I recently met my first group project here. File sharing and collaboration on programming can always be painful until version control systems come into play.

I have thought for a while how I could do this. Of course I could set up a public repository on GitHub, but it is often discouraged to make in-progress homework publicly available. I haven't paid for private repositories, nor have I applied for a student account, which can own a few private repositories. Therefore, I wonder whether I can host my repositories on campus, since CMU students have access to really powerful and convenient computing services.

It finally turned out that it is fairly easy. You don't need to run a Git server or SVN server (and you have no permission to do that) on Andrew machines. All you need is exploiting the power of Git and Andrew File System (AFS). However, I found that there is limited information about the method discussed below. (Is this a dark secret that all other guys already know? :P) The success of this method have made me rethink how Git works.

First you need to SSH to an Andrew Linux machine. Suppose that you want to set up a repository in ~/repos/project.git. You run the following commands, assuming that you are in your home directory after logging in.

mkdir repos/project.git
cd repos/project.git
git init --bare

The option --bare indicates that you want to initialize a server side copy of a Git repository, as is opposed to what we usually do to initialize a local copy.

Now you have a fresh git repository. You can clone it to your laptop.

git clone ssh://<andrew-id><andrew-id>/repos/project.git

usr# is the place in AFS that your home directory locates. Replace # with the actual number. Type pwd on an Andrew machine may give you a hint.

Next you need to grant access to your partners. Usually when you create a new directory, other users can only list its content. Only you can have read and write access to the directory. To check the access control for a directory, type fs la on the command line. If you want to revoke access of others, type the following command to make it private.

fs sa . <your-andrew-id> all -clear

Let's type the following command in your repository's directory.

fs sa . <partner-andrew-id> rlidwk

The magical rlidwk means (r)ead, (l)ookup, (i)nsert, (d)elete, (w)rite and loc(k). The missing permission is (a)dminister, since you don't want your partner to manage the repository.

If you have done the above before initializing the repository, then you are all set. However, if you want to grant permission after creating the repository (say if you have a new partner), you need to apply the rules to all previously created subdirectories. This can be finished using the command below.

find . -type d -print | xargs fs sa -acl <partner-andrew-id> rlidwk -dir

Then your partners can work on the shared repository. I repeat the git clone command below to highlight that two different Andrew IDs are used. Your partners should enter their own passwords when prompted.

git clone ssh://<partner-andrew-id><owner-andrew-id>/repos/project.git

Note that your partners should be able to list the content on all the upper level directories containing your repository. If your partners failed to clone the repository, ensure that they have the (l)ookup permission in these directories.

Now enjoy your project and appreciate the awesome Andrew File System and the flexibility in setting up Git version control!

Here are some useful links.