与集中式的版本管理工具不同, git采用分布式的版本管理方式. 由于最为广泛使用的git的仓库github只提供public的免费版本,所以更适合开源项目的管理,priavte仓库收费加之数据保留在远端的服务方式,很多企业需要创建供自己使用的github,功能非常类似的gitlab此时就能派上用场了。
Docker pull
# docker pull docker.io/gitlab/gitlab-ce
Docker run
事前准备
#mkdir -p /srv/gitlab/config /srv/gitlab/logs /srv/gitlab/data
docker run
docker run --detach \
--hostname host32 \
--publish 443:443 --publish 80:80 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
本地路径 | 容器内路径 | 说明 |
---|---|---|
/srv/gitlab/data | /var/opt/gitlab | gitlab仓库数据 |
/srv/gitlab/logs | /var/log/gitlab | log信息 |
/srv/gitlab/config | /etc/gitlab | gitlab设定文件 |
登陆画面
登陆URL | http://192.168.32.32 |
---|
登陆后画面
创建Group
创建后
创建Project
创建后
创建一个Readme文件
设定gitlab的ssh连接
本地的ssh的public key的内容(如果没有请用ssh-keygen生成)
[root@host32 ~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4D2H3/kkuRAb88tGyB83pvc0lGTEyOUa2nE4Lzi8YXC+7/o4oG3EQrhTNIMuMAh81ZqmdTwLNbI5yk6Q4GHkRpClYneX3yg7YG6uD2kJWeCAYDOFxPwB/HxvT9swhb5x3ZZXQ1bTLSS1SBxp6Fh5zQS8wkM/Ql1w9YPWx8+OY4VVa8CuhiCRpagM7fGhWjUH63MugGHiT5Ku7Ef6KvinK8ajES7K3EOkMm8noBYp0Da5D2Ggy6+dP7hrpv4XIQDe+lHfdC8eWhXW3kLY1bclLGq2I82S3+P0uzPgo437SDbj0+9JGg9clUTSnZBFUd6eO5WejgjgEmqTSw9/U10UD root@host32
[root@host32 ~]#
设定gitlab的ssh
使用git 与gitlab连接
使用git clone连接到gitlab
[root@host32 ~]# git clone http://192.168.32.32/devgroup/pilotproject.git
Cloning into 'pilotproject'...
Username for 'http://192.168.32.32': root
Password for 'http://root@192.168.32.32':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
[root@host32 ~]# ls -l pilotproject/
total 4
-rw-r--r--. 1 root root 5 Aug 6 06:20 README.md
[root@host32 ~]# cat pilotproject/README.md
hello[root@host32 ~]#
更新信息
[root@host32 ~]# cd pilotproject/
[root@host32 pilotproject]# ll
total 4
-rw-r--r--. 1 root root 5 Aug 6 06:20 README.md
[root@host32 pilotproject]# cat README.md
hello[root@host32 pilotproject]# echo "updated..." >>README.md
[root@host32 pilotproject]# cat README.md
helloupdated...
[root@host32 pilotproject]# git add README.md
[root@host32 pilotproject]# git commit -m "update"
[master a26e6f7] update
1 file changed, 1 insertion(+), 1 deletion(-)
[root@host32 pilotproject]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'http://192.168.32.32': root
Password for 'http://root@192.168.32.32':
Counting objects: 5, done.
Writing objects: 100% (3/3), 247 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.32.32/devgroup/pilotproject.git
f5b9ccd..a26e6f7 master -> master
[root@host32 pilotproject]#
从gitlab上确认更新的内容