ubuntu安装gitserver

安装 ```bash Terminal sudo apt-get install git-core sudo apt-get install python-setuptools



生成用户
```bash Terminal
sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /home/git \
    git
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

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

修改post-update权限

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

下载到客户端

git clone git@SERVER:gitosis-admin.git

添加新用户foo1

#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的项目

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
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

Comments