安装git
安装git自不必多说,源码编译安装和yum安装均可安装 gitosis
需要先安装 python-setuptools
yum install python-setuptools
安装gitosis
git clone https://github.com/tv42/gitosis.git cd gitosis/ python setup.py install
- 添加git用户
adduser --system --shell /bin/bash --comment 'Git' --create-home --home-dir /home/git/ git
- 导入管理员的public key
su - git
gitosis-init < id_rsa.pub
chmod 755 repositories/gitosis-admin.git/hooks/post-update
- 在本地获得gitosis-admin仓库
git clone git@xxxxxx:gitosis-admin.git
其中包括gitosis.conf , keydir两个文件
添加用户
把想要添加的用户的public key 放入 keydir内添加test用户的权限
在gitosis.conf文件中添加:[group test]
members = user1 user2 …….
writable = test将更改提交到线上
git commit -a -m 'add user'
git push
- 添加test项目代码
mkdir test
cd test
git init
git config user.name xxxxxx
git config user.email xxxxxxx
git remote add origin git@xxxxxx:test.git
git add .
git commit -a -m "initial import"
git push origin master