20140604 shared git server - plembo/onemoretech GitHub Wiki

title: shared git server link: https://onemoretech.wordpress.com/2014/06/04/shared-git-server/ author: phil2nc description: post_id: 7826 created: 2014/06/04 16:55:23 created_gmt: 2014/06/04 20:55:23 comment_status: closed post_name: shared-git-server status: publish post_type: post

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]. [code language="bash" gutter="false"] git clone --bare lemboscripts lemboscripts.git [/code] Then copy to server. [code language="bash" gutter="false"] scp -r lemboscripts.git server1:/data/share/git/ [/code] Get on server and re-initialize as shared bare repository. [code language="bash" gutter="false"] git init --bare --shared [/code] 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"). [code language="bash" gutter="false"] git clone server1:/data/share/git/lemboscripts.git [/code] 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".

Copyright 2004-2019 Phil Lembo