GitLab的安装及使用教程

 

1、配置yum源

vim /etc/yum.repos.d/gitlab-ce.repo

复制以下内容:

 

[gitlab-ce]

name=Gitlab CE Repository

baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/

gpgcheck=0

enabled=1

如果报错:

http://mirrors.cloud.aliyuncs.com/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.cloud.aliyuncs.com'"

Trying other mirror.

Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again

1、cd /etc/yum.repos.d

2、vim epel.repo

  nabled=1改为enabled=0 

2、更新本地yum缓存

sudo yum makecache

GitLab的安装及使用教程

3、安装GitLab社区版

sudo yum install gitlab-ce        #自动安装最新版
sudo yum install gitlab-ce-x.x.x    #安装指定版本

GitLab的安装及使用教程

GitLab常用命令

sudo gitlab-ctl start    # 启动所有 gitlab 组件;
sudo gitlab-ctl stop        # 停止所有 gitlab 组件;
sudo gitlab-ctl restart        # 重启所有 gitlab 组件;
sudo gitlab-ctl status        # 查看服务状态;
sudo gitlab-ctl reconfigure        # 启动服务;
sudo vim /etc/gitlab/gitlab.rb        # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;
sudo gitlab-ctl tail        # 查看日志;

GitLab使用

登录GitLab

1、在浏览器的地址栏中输入ECS服务器的公网IP即可登录GitLab的界面,第一次登录使用的用户名和密码为 root 和 5iveL!fe。

GitLab的安装及使用教程

2、首次登录会强制用户修改密码。密码修改成功后,输入新密码进行登录。

创建Project

1、安装Git工具linux:安装Git,使用自带的源安装。

yum install git

GitLab的安装及使用教程

2、生成密钥文件:使用ssh-keygen生成密钥文件.ssh/id_rsa.pub。

GitLab的安装及使用教程

GitLab的安装及使用教程

3.在GitLab的主页中新建一个Project

GitLab的安装及使用教程

GitLab的安装及使用教程

4.添加ssh key导入步骤2中生成的密钥文件内容:

GitLab的安装及使用教程

GitLab的安装及使用教程

ssh key添加完成:

GitLab的安装及使用教程

项目地址,该地址在进行clone操作时需要用到:

GitLab的安装及使用教程

简单配置

1、配置使用Git仓库的人员姓名(以上海驻云为例)

git config --global user.name "上海驻云" 

2、配置使用Git仓库的人员email,填写自己的公司邮箱

git config --global user.email "support@jiagouyun.com" 

3、克隆项目,在本地生成同名目录,并且目录中会有所有的项目文件

git clone git@iZbp1h7fx16gkr9u4gk8v3Z:root/test.git

GitLab的安装及使用教程

上传文件

1、进入到项目目录

cd test/ 

2、创建需要上传到GitLab中的目标文件

echo “test” >  /root/test.sh

3、将目标文件或者目录拷贝到项目目录下

cp /root/test.sh ./  

GitLab的安装及使用教程

4、将test.sh文件加入到索引中

git add test.sh 

5、将test.sh提交到本地仓库

git commit -m “test.sh”

6、将文件同步到GitLab服务器上

git push -u origin master 

GitLab的安装及使用教程

7、在网页中查看上传的test.sh文件已经同步到GitLab中

GitLab的安装及使用教程

 

参考文章: https://yq.aliyun.com/articles/74395

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值