shared git server

Another milestone in my Git Conversion Project. Setting up a shared git repository on a server.

My primary resource here was the free online copy of Scott Chacon’s Pro Git, especially the section entitled Getting Git on a Server.

In this example my server filesystem layout was pretty basic. I created a git system user and made its home /data/share/git[1], then made sure all my developer users were in the local git group.

If you’ve got an existing repository, create a bare clone[2].

git clone --bare lemboscripts lemboscripts.git

Then copy to server.

scp -r lemboscripts.git server1:/data/share/git/

Get on server and re-initialize as shared bare repository.

git init --bare --shared

The “–shared” switch sets permissions so that anyone in the same local group as git can write to that directory[3].

Finally, go back to client(s) and clone from server (making sure that any existing “lemboscripts” folder has been renamed to say, “lemboscripts.bak”).

git clone server1:/data/share/git/lemboscripts.git

This new clone of the repository (with working directory) will then appear as lemboscripts[4].

Notes:

[1] Did a “groupadd -g 1011 git” and then “useradd -g git -u 1011 -c ‘Git User’ -d /data/share/git git”.

[2] A bare clone is a copy of the repository without the working directory (where you work on the files). It will look as if you did a “cp -R lemboscripts/.git/* lemboscripts.git/”.

[3] For good measure I did a “chown -R git:git” and “chmod -R g+w” against git’s home, and made sure all the dot bash files were in place.

[4] On my workstation I performed the cloning operation under a new $HOME/git directory, and so wound up with “$HOME/git/lemboscripts”.

This entry was posted in Development, System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).