博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
20190419 Gitlab部分
阅读量:7091 次
发布时间:2019-06-28

本文共 5996 字,大约阅读时间需要 19 分钟。

准备环境:172.18.9.200是gitlab、172.18.9.201是jenkins

Git是gitlab的客户端命令,gitlab是应用程序

一、使用清华大学的镜像:

rpm包国内下载地址:

20190419    Gitlab部分

二、[root@centos7 src]#yum install -y gitlab-ce-11.9.8-ce.0.el7.x86_64.rpm

(注:我在此处停留很久,因为我yum时总是报错“Nothing to do”,只要我们mount上光盘,配好epel源aliyun的镜像即可yum了,因为此时源码包已上传至虚拟机,这时下载源码包已经和yum源没关系了)

三、[root@centos7 src]#vim /etc/ssh/sshd_config

port=2022 #默认为22,必改

四、[root@centos7 src]#vim /etc/gitlab/gitlab.rb

external_url '' 此项改为IP,是为了让开发人员能连上我们。

###Email Settings
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "rooroot@163.com"
gitlab_rails['smtp_password'] = "zhang@123"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = "rooroot@163.com"
user["git_user_email"] = rooroot@"163.com" 该处的“”必须加上,

五、一条命令查看gitlab的相关插件:

[root@200 ~]#gitlab-

gitlab-ctl gitlab-psql gitlab-rails gitlab-rake

六、重新编译:[root@200 ~]#gitlab-ctl reconfigure
七、查看状态:[root@200 src]#gitlab-ctl status

run: alertmanager: (pid 30017) 149s; run: log: (pid 29629) 188s

run: gitaly: (pid 29893) 154s; run: log: (pid 28314) 338s
run: gitlab-monitor: (pid 29950) 153s; run: log: (pid 29390) 212s
run: gitlab-workhorse: (pid 29911) 154s; run: log: (pid 29077) 243s
run: logrotate: (pid 29207) 233s; run: log: (pid 29228) 230s
run: nginx: (pid 29144) 239s; run: log: (pid 29167) 236s

八、访问测试:

20190419    Gitlab部分

九、

20190419    Gitlab部分

十、点击USE1 new user后,操作如下:
十一、务必时间同步,重启gitlab后就可以继续操作了,时间不同步结果就失败:

[root@200 src]#ntpdate 172.18.0.1

23 Apr 11:41:27 ntpdate[32929]: adjust time server 172.18.0.1 offset -0.188343 sec
[root@200 src]#gitlab-ctl restart
ok: run: alertmanager: (pid 32972) 0s
ok: run: gitaly: (pid 32987) 0s
ok: run: nginx: (pid 33037) 1s

十二、创建组:

20190419    Gitlab部分

20190419    Gitlab部分

十三、创建项目:

20190419    Gitlab部分

20190419    Gitlab部分
20190419    Gitlab部分

十四、创建新文件:点击提交,第一个版本就被放在仓库里了:

20190419    Gitlab部分

十五、在201主机安装git: [root@201 ~]#yum install -y git
十六、我们在201主机克隆git:

[root@201 ~]#git clone

Cloning into 'web1'...
Username for '': Leslie #这是name
Password for '':
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
[root@201 ~]#ll
total 12
drwxr-xr-x. 3 root root 36 Apr 23 12:23 web1
[root@201 ~]#cd web1/
[root@201 web1]#ll
total 4
-rw-r--r--. 1 root root 23 Apr 23 12:23 index.html
[root@201 web1]#vim index.html
马哥教育Linux 35 v1

十七、新建一个测试页:

20190419    Gitlab部分

十八、执行Git config --global:

[root@201 ~]#git config --global user.name "user1"

[root@201 ~]#git config --global user.email "test.@qq.com"
[root@201 ~]#cd web1/
[root@201 web1]#vim index.html
马哥教育 Linux 35 v1
马哥教育 Linux 35 v2
[root@201 web1]#git add ./*
[root@201 web1]#git commit -m "v2"
[master ca130ab] v2
1 file changed, 2 insertions(+), 1 deletion(-)
[root@201 web1]#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 '': Leslie

Password for '':
Counting objects: 5, done.
Writing objects: 100% (3/3), 258 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To
3af0975..ca130ab master -> master #默认是master

十九、找到web2,这是第一台服务器就可以进行git push拉取了。

20190419    Gitlab部分

二十、查看分支:[root@201 web1]#git branch
  • master
    二十一、添加一个分支,这时,我们再去git checkout branch时要加“-b”参数:

    20190419    Gitlab部分

    二十二、[root@201 web1]#git checkout -b develop

    Switched to a new branch 'develop'

    [root@201 web1]#git branch

  • develop

    master
    {插播:如何寻找develop分支的clone}:
    步骤:Groups,web35,web1,点击“+”,创建新branch,再返回web1点击“clone”,即可!!

    二十三、我们克隆一个分支:develop

    [root@200 src]#git clone -b develop

    Cloning into 'web1'...
    Username for '': Leslie
    Password for '':
    remote: Enumerating objects: 6, done.
    remote: Counting objects: 100% (6/6), done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 6 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (6/6), done.

    二十四、[root@200 web1]#vim web1/index.html

    马哥教育Linux 35 v1

    马哥教育Linux 35 v2
    马哥教育Linux 35 v3 #这些内容只有经过测试才会被发布到线上

    二十五、[root@200 web1]#git commit -m "v3"

    [develop 89e511c] v3

    1 file changed, 2 insertions(+)
    [root@200 web1]#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 '': Leslie

Password for '':
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 266 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for develop, visit:
remote:
remote:
To
ca130ab..89e511c develop -> develop

二十六、Gitlab 回滚:

20190419    Gitlab部分

回滚到v1:
20190419    Gitlab部分

二十七:git 常用命令:

git config --globaluser.name “name“ #设置全局用户名

git config --globaluser.email xxx@xx.com#设置全局邮箱
git config --global –list #列出用户全局设置
git add index.html / . #添加指定文件、目录或当前目录下所有数据到暂存区
git commit -m“11“ #提交文件到工作区
gitstatus #查看工作区的状态
git push #提交代码到服务器
git pull #获取代码到本地
gitlog #查看操作日志
vim . gitignore #定义忽略文件
基于仓库的回滚:git reset --hard HEAD^^ #git 版本回滚, HEAD 为当前版本,加一个^为上一个,^^为上上一个版本
gitreflog # #获取每次提交的 ID,可以使用--hard 根据提交的 ID 进行版本回退
gitreset --hard 5ae4b06 #回退到指定 id 的版本
#git branch #查看当前所处的分支
#git checkout -b develop #创建并切换到一个新分支
#git checkout develop #切换分支

转载于:https://blog.51cto.com/14128387/2385664

你可能感兴趣的文章
UVA 1426 - Discrete Square Roots(数论)
查看>>
怎样优化cocos2d/x程序的内存使用和程序大小
查看>>
Redis的三种启动方式
查看>>
YII框架分析笔记2:组件和事件行为管理
查看>>
iptables启动脚本分析
查看>>
进阶之路(基础篇) - 013 通过读取可变电阻值调节流水灯的速度
查看>>
GG链路过多port不足导致的报错OGG-01223
查看>>
自然语言交流系统 phxnet团队 创新实训 个人博客 (八)
查看>>
talk is cheap, show me the code——dcgan,wgan,wgan-gp的tensorflow实现
查看>>
Kettle学习系列之数据仓库、数据整合、ETL、ELT和EII之间的区别?
查看>>
把握linux内核设计思想系列
查看>>
zoj1003 Crashing Balloon
查看>>
在EA中将画出的ER图转换成SQL脚本
查看>>
Android Studio怎样删除module
查看>>
selective search生成.mat文件
查看>>
POJ2823 Sliding Window【双端队列】
查看>>
ssh-remote-port-forwarding
查看>>
System V IPC(1)-消息队列
查看>>
51单片机GPIO口模拟串口通信
查看>>
信息、数据与数据结构
查看>>