Ubuntu安装gitserver

安装

Terminal
1
2
sudo apt-get install git-core
sudo apt-get install python-setuptools

生成用户

Terminal
1
2
3
4
5
6
7
8
sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /home/git \
    git
Terminal
1
2
3
4
5
mkdir ~git/src && cd ~git/src
git clone https://github.com/tv42/gitosis.git

cd ~git/src/gitosis
python setup.py install

初使化gitosis,上传id_rsa.pub

1
sudo -H -u git gitosis-init < /tmp/id_rsa.pub

修改post-update权限

1
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

下载到客户端

1
git clone git@SERVER:gitosis-admin.git

添加新用户foo1

1
2
3
4
5
#id_rsa.pub 取到新用户的公钥复制到keydir下:如:
cp id_rsa.pub ./keydir/foo1@gmail.com.pub
git add ./keydir/foo1@gmail.com.pub
git commit -m 'add new user dev key'
git push

建立一个叫做foo的项目

1
2
3
4
5
6
7
8
9
10
11
vi gitosis.conf

[gitosis]

[group gitosis-admin]
writable = gitosis-admin
members = xxxx@gmail.com

[group foo]
writable = foo
members = foo1@gmail.com foo2@gmail.com
1
2
3
4
5
6
7
8
mkdir foo && cd foo

git init
touch hello.txt
git add hello.txt
git commit -am 'first commit'
git remote add origin git@SERVER:foo.git
git push origin master

参考

http://www.guztech.nl/wordpress/index.php/2010/02/setting-up-a-git-server-in-ubuntu-with-gitosis-and-using-gitextensions-on-windows/

https://github.com/tv42/gitosis

原文地址:http://dlj.bz/jhRwMT

Comments