一、安装gitlab-ce-12.10.1
下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/
1.安装插件
yum -y install curl policycoreutils openssh-server openssh-clients policycoreutils-python-utils
2.安装gitlab
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-13.9.3-ce.0.el8.x86_64.rpm
[root@master ~]# rpm -ivh gitlab-ce-13.9.3-ce.0.el8.x86_64.rpm
警告:gitlab-ce-13.9.3-ce.0.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID f27eab47: NOKEY
Verifying...
################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:gitlab-ce-13.9.3-ce.0.el8 ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=13-9
由于是rpm方式安装,安装的包的位置默认是在/opt/下
3.配置gitlab域名
vim /etc/gitlab/gitlab.rb
改:external_url 'http://gitlab.example.com'
修改:external_url 'http://192.168.79.128' #自己的本机IP
#改好后,重启gitlab 加载配置 大概 2~3分钟
gitlab-ctl reconfigure
#查看状态
[root@master ~]# gitlab-ctl status
run: alertmanager: (pid 7468) 98s; run: log: (pid 6806) 136s
run: gitaly: (pid 1882) 343s; run: log: (pid 1881) 343s
run: gitlab-exporter: (pid 1905) 343s; run: log: (pid 1904) 343s
run: gitlab-workhorse: (pid 1903) 343s; run: log: (pid 1902) 343s
run: grafana: (pid 7484) 97s; run: log: (pid 7457) 99s
run: logrotate: (pid 1895) 343s; run: log: (pid 1894) 343s
run: nginx: (pid 7438) 100s; run: log: (pid 1898) 343s
run: node-exporter: (pid 1901) 343s; run: log: (pid 1900) 343s
run: postgres-exporter: (pid 7477) 98s; run: log: (pid 6832) 132s
run: postgresql: (pid 1890) 343s; run: log: (pid 1889) 343s
run: prometheus: (pid 7450) 99s; run: log: (pid 6754) 143s
run: puma: (pid 1897) 343s; run: log: (pid 1892) 343s
run: redis: (pid 1879) 343s; run: log: (pid 1878) 343s
run: redis-exporter: (pid 7444) 99s; run: log: (pid 6721) 150s
run: sidekiq: (pid 1896) 343s; run: log: (pid 1893) 343s
内存要大于4G,不然gitlab-ctl reconfigure 时会卡死
4.登录网页
第一次登录需要确认密码
去修改个人设置
修改成中文显示
二、gitlab日常使用
gitlab-ctl的使用:
关闭gitlab: # gitlab-ctl stop
启动gitlab: # gitlab-ctl start
重启gitlab: # gitlab-ctl restart
gitlab主配置文件:/etc/gitlab/gitlab.rb //可以自定义一些邮件服务等
日志地址:/var/log/gitlab/ // 对应各服务
服务地址:/var/opt/gitlab/ // 对应各服务的主目录
仓库地址:/var/opt/gitlab/git-data //记录项目仓库等提交信息
重置配置:gitlab-ctl reconfigure //不要乱用,会重置为最原始的配置的
重启服务:gitlab-ctl stop/start/restart //启动命令
(一)、创建群组
1、新建项目前,先创建项目所在的组(也就是说这个项目文件是保存在哪个组里)
点击创建即可
(二)、新建项目
创建完项目,它会有初始化仓库的提示命令
选择新建文件,写入一个html 语言,提交
三、安装git客户端使用gitlab
#安装git
[root@master ~]# dnf -y install git
选择第二个进行克隆,ssh 现在没设置密钥
[root@master ~]# git clone http://192.168.79.128/devops/test_web.git
正克隆到 'test_web'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
展开对象中: 100% (3/3), 232 字节 | 232.00 KiB/s, 完成.
git常用命令:
git config --global user.name “name“ #设置全局用户名
git config --global user.email mail #设置全局邮箱
git config --global --list #列出用户全局设置
git add index.html #添加文件到暂存区
git commit -m “描述内容“ #提交文件到工作区
git status #查看工作区的状态
git push #提交代码到git服务器上
git pull #获取代码到本地
git log #查看操作日志
vim .gitignore #定义忽略文件
git reset --hard HEAD^ #git版本回滚, HEAD为当前版本,加一个^为上一个,^^为上上一个版本
git reflog #获取每次提交的ID,可以使用--hard根据提交的ID迚行版本回退
git reset --hard 5ae4b06 #回退到指定id的版本
git branch #查看当前所处的分支
git checkout -- file #从服务器更新某个那文件覆盖本地的文件