私有仓库 gitlab 部署笔记

时间:2019-03-19
本文章向大家介绍私有仓库 gitlab 部署笔记,主要包括私有仓库 gitlab 部署笔记使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

--------------------------------------------gitlab简介-------------------------------------------------------

1.什么是gitlab

GitLab 是一个用于仓库管理系统的开源项目。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。可通过Web界面进行访问公开的或者私人项目。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用

2.常用的网站

官网:https://about.gitlab.com/

国内镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/

---------------------------------------------------------------------------------------------------------------------------------------

>>环境简述:

1.服务器系统环境:

[root@bogon liujiingCode]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

[root@bogon liujiingCode]# cat /etc/hosts|grep 192.168.10.128
192.168.10.128 www.liujing.com

>>部署gitlab

1.安装gitlab依赖包

[root@bogon ~]# yum install -y curl policycoreutils-python openssh-server openssh-clients

2.下载gitlab的rpm 包

[root@bogon ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.6-ce.0.el7.x86_64.rpm

3.通过yum 本地安装Gitlab

[root@www download]# yum -y localinstall gitlab-ce-10.0.6-ce.0.el7.x86_64.rpm

4.修改gitlab的主配置文件

vim  /etc/gitlab/gitlab.rb(下图中192.168.10.128改成自己gitlab服务器的IP地址或域名)

  

 5.初始化gitlab,只执行一次

[root@www download]# gitlab-ctl reconfigure ####时间有点长,耐心等待

6.管理gitlab的常用命令

[root@www download]#gitlab-ctl  start  ##启动gitlab服务
[root@www download]#gitlab-ctl  stop   ##停止gitlab服务
[root@www download]#gitlab-ctl  status ##查看gitlab的状态

7.通过webUI 访问gitlab,设置初始密码(下图是拷贝的)

 8.登录gitlab

 9.登录成功后会有以下界面

10.gitlab的安装和存放目录

  >安装目录:

  >日志存放目录

  

  >配置文件存放目录

 -----------------------------------------------使用gitlab-----------------------------------

>>使用gitlab步骤详解

1.点击新建项目

2.编辑新建项目信息

 3.创建项目成功后的界面

 4.配置秘钥登录-点击“add an ssh key”

 5.将服务器端的公钥复制到gitlab的webUI界面上

 6.配置秘钥登录-配置成功的界面(图片拷贝的)

 7.创建新仓库-查看帮助信息

 8.创建新仓库-克隆gitlab的项目到服务器本地

  >.将gitlab的数据下载到本地服务器中

  [root@yinzhengjie ~]# ll
  total 0
  drwxr-xr-x 2 root root 83 Sep 9 01:50 download
  drwxr-xr-x 3 root root 45 Sep 8 23:13 git_data
  [root@yinzhengjie ~]#
  [root@yinzhengjie ~]# git clone git@www.yinzhengjie.org.cn:root/yinzhengjieCode.git
  Cloning into 'yinzhengjieCode'...
  The authenticity of host 'www.yinzhengjie.org.cn (172.30.1.101)' can't be established.
  ECDSA key fingerprint is SHA256:1MkICaFrw0jl80J9+gRJBa4W1QjDRafGqrFzRzae81E.
  ECDSA key fingerprint is MD5:b6:44:e8:e7:76:d4:c2:4c:e0:02:7e:9c:d8:59:d8:13.
  Are you sure you want to continue connecting (yes/no)? yes
  Warning: Permanently added 'www.yinzhengjie.org.cn' (ECDSA) to the list of known hosts.
  warning: You appear to have cloned an empty repository.
  [root@yinzhengjie ~]#
  [root@yinzhengjie ~]# ll
  total 0
  drwxr-xr-x 2 root root 83 Sep 9 01:50 download
  drwxr-xr-x 3 root root 45 Sep 8 23:13 git_data
  drwxr-xr-x 3 root root 17 Sep 9 04:08 yinzhengjieCode
  >.将数据推送到gitlab中

  [root@yinzhengjie ~]# cd yinzhengjieCode/
  [root@yinzhengjie yinzhengjieCode]#
  [root@yinzhengjie yinzhengjieCode]# ll
  total 0
  [root@yinzhengjie yinzhengjieCode]#
  [root@yinzhengjie yinzhengjieCode]# touch README.md
  [root@yinzhengjie yinzhengjieCode]# echo http://www.cnblogs.com/yinzhengjie >> README.md
  [root@yinzhengjie yinzhengjieCode]# git add README.md
  [root@yinzhengjie yinzhengjieCode]# git commit -m "add README"
  [master (root-commit) 64b2f56] add README
  file changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 README.md
  [root@yinzhengjie yinzhengjieCode]# git push -u origin master #将数据推送到gitlab中
  Counting objects: 3, done.
  Writing objects: 100% (3/3), 217 bytes | 0 bytes/s, done.
  Total 3 (delta 0), reused 0 (delta 0)
  To git@www.yinzhengjie.org.cn:root/yinzhengjieCode.git
  * [new branch] master -> master
  Branch master set up to track remote branch master from origin.

 9.在网页上编辑

 10.在网页上编辑完成后点击提交并查看修改后的内容

11.在服务器端查看修改的内容

[root@www liujiingCode]# ls
README.md
[root@www liujiingCode]# cat README.md
http://www.cnblogs.com/liujing


刘敬,到此一游

大数据

人工智能

自动化运维