准备
gitosis
添加用户
仓库服务器执行
1 2 3
| useradd git mkdir -p /home/git chown -R git:git /home/git
|
密钥
1
| cp ~/.ssh/id_rsa.pub /tmp/git.pub
|
安装
1 2 3
| git clone git://github.com/res0nat0r/gitosis.git cd gitosis python setup.py install
|
初始化
1 2
| su git gitosis-init < ~/.ssh/id_rsa.pub
|
管理
拉取
1 2 3 4 5 6
| $git clone git@192.168.16.232:repositories/gitosis-admin.git $ tree -L 2 gitosis-admin gitosis-admin ├── gitosis.conf └── keydir └── git@ubuntu.pub
|
配置密钥
1
| cp ~/.ssh/id_rsa.pub gitosis-admin/keydir/cs.pub
|
添加权限 gitosis.conf
1 2 3
| [group dev] members = cs #这里的cs对上面公匙cs.pub文件名cs writable = test #项目名test
|
测试拉取
1 2 3 4 5 6 7
| mkdir test && cd test echo "测试test仓库">rep git init git add . git commit -am "add test" git remote add origin git@192.168.16.232:test.git git push origin master
|
提示要密码
设置密码(root用户操作)
或
1 2
| su gits echo "你的密钥">>~/.ssh/authorized_keys
|
gitolite
添加用户
仓库服务器执行
1 2 3
| useradd gits mkdir -p /home/gits chown -R gits:gits /home/gits
|
初始化
1 2 3 4 5
| $ cp ~/.ssh/id_rsa.pub /tmp/git.pub $ su gits $ git clone https://github.com/sitaramc/gitolite $ gitolite/install -to $HOME/bin $ ~/bin/gitolite setup -pk /tmp/git.pub
|
密码
见gitosis测试拉取的操作
管理
本地拉取
1
| git clone gits@192.168.16.232:repositories/gitolite-admin
|
正克隆到 ‘gitolite-admin’…
gits@192.168.16.232‘s password:
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
接收对象中: 100% (6/6), 完成.
检查连接… 完成。
查看目录
1 2 3 4 5 6
| $ tree -L 2 gitolite-admin gitolite-admin ├── conf │ └── gitolite.conf └── keydir └── git.pub
|
cp密钥,配置权限
1 2 3 4 5 6
| $ cat gitolite-admin/conf/gitolite.conf repo gitolite-admin RW+ = git
repo testing RW+ = @all
|
RW+ 所有权限
doc: https://github.com/sitaramc/gitolite#access-rule-examples
最后
1 2 3
| git add . git commit -am "add new user xx" git push origin master
|
更多高级配置在/home/gits/.gitolite.rc
gogs
官网 https://try.gogs.io/
带UI的服务,部署方便,轻量级
gitlab太占内存了,云服务器跑成本高呀
1 2 3 4 5 6 7 8 9 10 11
| # Pull image from Docker Hub. $ docker pull gogs/gogs
# Create local directory for volume. $ mkdir -p /var/gogs
# Use `docker run` for the first time. $ docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs
# Use `docker start` if you have stopped it. $ docker start gogs
|
doc https://github.com/gogits/gogs/tree/master/docker#usage
drone CICD
https://docs.drone.io/server/provider/gogs/