GitLab
GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
GitLab是由GitLabInc.开发,使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
1.配置yum源
[[email protected] ~]# vim /etc/yum.repos.d/yum.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
Repo_gpgcheck=0
Enabled=1
gpgcheck=0
2.更新本地yum缓存
[[email protected] ~]# yum makecache #更新本地yum缓存
3. 安装GitLab社区版
[[email protected] ~]# yum install gitlab-ce.x86_64 -y #安装GitLab社区版
4.设置GitLab访问IP
[[email protected] ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.74.12' #访问gitlab的地址 可以是内网IP也可以是公网ECS服务器的公网IP
[[email protected] ~]# gitlab-ctl reconfigure #重载服务
# 过程较长耐心等待
GitLab常用命令
gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
gitlab-ctl reconfigure # 启动服务;
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
gitlab-ctl tail # 查看日志;
登录GitLab
第一次登录使用的用户名和密码为 root 和 5iveL!fe。
首次登录会强制用户修改密码。密码修改成功后,输入新密码进行登录。
创建Project
1. 安装Git
[[email protected] ~]# yum install -y git
2. 生成**文件
[[email protected] ~]# ssh-****** #一路回车
3.在GitLab的主页中新建一个Project
4.添加ssh key导入步骤2中生成的**文件内容:
ssh key添加完成:
配置用户信息
# 配置使用Git仓库的人员姓名
[[email protected] ~]# git config --global user.name "燕子李三"
# 配置使用Git仓库的人员email,填写自己的公司邮箱创建需要上传到GitLab中的目标文件
[[email protected] ~]# git config --global user.email "[email protected]"
查看列表
[[email protected] ~]# git config --global --list
user.name=燕子李三
[email protected]
克隆项目,在本地生成同名目录,并且目录中会有所有的项目文件
[[email protected] ~]# git clone [email protected]:root/test.git
正克隆到 'test'...
创建需要上传到GitLab中的目标文件
1、进入到项目目录
[[email protected] ~]# cd test/
2、创建需要上传到GitLab中的目标文件
[[email protected] test]# cp /root/test.sh ./
3、 将目标文件或者目录拷贝到项目目录下
[[email protected] test]# cp /root/test.sh ./
4、将test.sh文件加入到索引中
[[email protected] test]# git commit -m test.sh
5、将test.sh提交到本地仓库
[[email protected] test]# git push -u origin master
6、将文件同步到GitLab服务器上
[[email protected] test]# git push -u origin master
在网页中查看上传的test.sh文件已经同步到GitLab中