複数人でgitレポジトリを共有する方法

sshを通してgitを利用する場合はgitを共有して利用するためのグループを作り, そのグループにパーミションを付与する.

管理側:
gitグループを追加
% sudo pw groupadd git
taroユーザを追加
% sudo adduser taro
taroユーザをgitグループに追加
% sudo pw usermod -n taro -G taro,wheel,git

ユーザ側:
% sudo mkdir hoge.git
% cd hoge.git
% sudo git init –bare –shared

% cd ..
% chgrp -R git hoge.git
% ls -l
drwxrwsr-x 7 root git 4096 6月 18 00:42 hoge.git

taro% mkdir hoge
taro% cd hoge
taro% git init
taro% git remote add origin ssh://taro@hogehoge.com/var/git/hoge.git #ローカルリポジトリに共有リポジトリを登録
taro% touch README
taro% git add .
taro% git commit -m “Initial import”
taro% git push origin master #共有リポジトリ(origin)にローカルリポジトリ(master)の更新を反映

参考:

続 せっかちな人のための git 入門 – 共有リポジトリの作り方 – 僕は発展途上技術者