持续化集成工具-gitlab

1.版本控制系统简介
版本控制系统是一种记录活若干个文件内容变化,以便将来查阅特定版本内容情况的系统记录文件的所有历史变化,随时可恢复到任何一个历史状态,多人协作开发。
安装:
yum -y install git
[root@iZ0qjhhu2rrhmpZ ~]# git config
Config file location
–global use global config file
–system use system config file
–local use repository(版本库级) config file

[root@iZ0qjhhu2rrhmpZ ~]# git config --global user.name ‘xu’
[root@iZ0qjhhu2rrhmpZ ~]# git config --global user.email ‘xdienoe@163.com’
[root@iZ0qjhhu2rrhmpZ ~]# git config --global color.ui true
[root@iZ0qjhhu2rrhmpZ ~]# git config --list
user.name=xu
user.email=xdienoe@163.com
color.ui=true

[root@iZ0qjhhu2rrhmpZ ~]# cat .gitconfig
[user]
name = xu
email = x@163.com
[color]
ui = true

3.git初始化
初始化工作目录,对已存在的目录可进行初始化版本仓库(可以是空的目录,也可以是带内容的目录)
mkdir /home/git_data
cd /home/git_data
初始化工作目录,对已存在的目录可进行初始化版本仓库(可以是空的目录,也可以是带内容的目录)
git init
查看工作区状态
git status
隐藏文件介绍
branchec 分支目录
config 定义项目特有的配置选项
description 仅供git web程序使用
HEAD 指定当前的分支
hooks 包含git钩子文件
info 包含一个全局排除文件(exclude文件)
objects 存放所有数据内容,有info和pack两个子文件夹
refs 存放指向数据(分支)的提交对象的指针
index 保存暂存区信息,在执行git init的时候,这个文件还没有

git add file 添加文件到暂存区
git add . 或者git add * 添加所有文件到暂存区
删除文件
1.先从暂存区撤回到工作区,然后直接删除文件
git rm --cacaed filename
rm -rf filename
2.直接从暂存区域同工作区域一同删除文件命令
git rm -rf filename
代码提交 从缓存区提交到本地仓库
git commit -m “commit test”

git mv old-filename new-filename 直接更改文件名称 更改完直接commit提交即可
git diff 默认比对工作目录和暂存区有什么不同
git diff --cached 比对暂存区和本地仓库
如果某个文件已经被仓库管理,如果在更改此文件直接需要一条命令提交即可
git commit -am “add bewfile”
git log 查看历史提交过的信息
git log --oneline一行显示详尽信息
git log --oneline --decorate 当前指针指向的位置
git log -p 显示具体内容变化
git log -1只显示一条内容
git reset --hard 4a6dee0fd7 回滚数据到4a6dee0fd7哈希所代表的版本
git log --oneline --decorate 查看当前指针的指向
git branch testing 创建testing分支
[root@iZ0qjhhu2rrhmpZ git_data]# git branch

  • master *在那里说明在那个分支上
    testing
    git checkout 分支名 切换分支
    [root@iZ0qjhhu2rrhmpZ git_data]# git checkout testing
    Switched to branch ‘testing’
    [root@iZ0qjhhu2rrhmpZ git_data]# git branch
    master
  • testing
    git checkout -b 分支名 创建并切换到分支
    git branch -d 分支名称 删除分支

git标签使用使用
标签也是指向了一次commit提交,是一个里程碑式的标签,回滚打标签直接打标签号,不需要加唯一字符串不好记
git tag -a V1.0 832c231 -m “echo fefafwfgg > master” -a指定标签名字 -m 指定说明文字
[root@iZ0qjhhu2rrhmpZ git_data]# git tag
V1.0
V1.1
[root@iZ0qjhhu2rrhmpZ git_data]# git show V1.0 查看V1.的信息, git show 加标签查看
tag V1.0
Tagger: xu xdienoe@163.com
Date: Tue May 19 10:15:53 2020 +0800

add index 2726db0

commit 2726db087d0f6462c1bf839ec1794d2ff11b8d32
Author: xu xdienoe@163.com
Date: Mon May 18 16:43:04 2020 +0800

2 index

diff --git a/0 b/0
new file mode 100644
index 0000000…e69de29
diff --git a/2 b/2
index e69de29…9015a7a 100644
— a/2
+++ b/2
@@ -0,0 +1 @@
+index

git reset --hard V1.0 直接还原数据到V1.0

git tag -d V1.0 删除标签 -d参数
[root@iZ0qjhhu2rrhmpZ git_data]# git tag
V1.0
V1.1
[root@iZ0qjhhu2rrhmpZ git_data]# git tag -d V1.0
Deleted tag ‘V1.0’ (was 0427922)
[root@iZ0qjhhu2rrhmpZ git_data]# git tag
V1.1

git remote add origin git@github.com:dienoe/git_data.git 添加远程仓库 姓名为origin
git remote 查看当前的远程仓库的名称
生成密钥
ssh-keygen -t rsa
cd ~
cat ./ssh/id_rsa.pub

GitLab简介:

GitLab是一个用于仓库管理系统的开源项目。使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。可通过Web界面进行访问公开的或者私人项目。它拥有GitHub类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供了一个代码片段收集功能可以轻松实现代码复用。
/etc/gitlab/gitlab.rb #gitlab配置文件
/opt/gitlab #gitlab的程序安装目录
/var/opt/gitlab #gitlab目录数据目录
/var/opt/gitlab/git-data #存放仓库数据
gitlab-ctl reconfigure #重新加载配置
gitlab-ctl status #查看当前gitlab所有服务运行状态
gitlab-ctl stop #停止gitlab服务
gitlab-ctl stop nginx #单独停止某个服务
gitlab-ctl tail #查看所有服务的日志

Gitlab的服务构成:
nginx: 静态web服务器
gitlab-workhorse 轻量级反向代理服务器
logrotate 日志文件管理工具
postgresql 数据库
redis 缓存数据库
sidekiq 用于在后台执行队列任务(异步执行)

安装环境:

(1)CentOS 6或者7 (此处使用7)
(2)2G内存(实验)生产(至少4G),不然会很卡
(3)安装包:gitlab-ce-10.2.2-ce
(4)禁用防火墙,关闭selinux
安装步骤:

(1)安装软件

[root@gitlab ~]# yum install -y curl policycoreutils-python openssh-server #安装依赖
[root@gitlab ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm #下载软件包
[root@gitlab ~]# rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm #安装gitlab

(2)根据安装完成提示界面进行访问URL更改及重新加载配置文件 更改次选项为自己的域名或者IP external_url ‘http://gitlab.example.com’

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb #编辑配置文件
external_url ‘http://192.168.1.21’ #改为自己的IP地址
[root@gitlab ~]# gitlab-ctl reconfigure #重新加载配置文件
(3)重装完成访问http://192.168.1.21,会首先叫更改密码(root用户),改完后登录。如下界面:

(4)汉化
1、下载汉化补丁
[root@gitlab ~]# git clone https://gitlab.com/xhang/gitlab.git
[root@gitlab ~]# cd gitlab
2、查看全部分支版本
[root@gitlab ~]# git branch -a
3、对比版本、生成补丁包
[root@gitlab ~]# git diff remotes/origin/10-2-stable remotes/origin/10-2-stable-zh > /tmp/10.2.2-zh.diff
4、停止服务器
[root@gitlab ~]# gitlab-ctl stop
5、打补丁
[root@gitlab ~]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/10.2.2-zh.diff
6、启动和重新配置
[root@gitlab ~]# gitlab-ctl start
[root@gitlab ~]# gitlab-ctl reconfigure

git remote remove origin 删除远程连接仓库加粗样式

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值