镜像容器 gitlab pull 代码到本地 教程

基于docker容器 gitlab pull 代码到centos 教程

以Gitlab 是镜像容器,映射的端口的 7080:80 , 2222:22为例

首先,我们要配置 gitlab.example.com 的域名的hosts

vim /etc/hosts
192.168.160.3 gitlab.example.com

cd 到 ~/.ssh 目录下

vim config
#将以下配置内容添加进去
Host gitlab.example.com
       HostName gitlab.example.com
       IdentityFile ~/.ssh/id_rsa
       PreferredAuthentications publickey
       Port 2222           
 # 配置文件参数
 # Host : Host可以看作是一个你要识别的模式,对识别的模式,进行配置对应的的主机名和ssh文件
 # HostName : 要登录主机的主机名
 # User : 登录名
 # IdentityFile : 指明上面User对应的identityFile路径

以上操作是为了 ssh 方式拉去代码

接下来我们要生成公钥

ssh-keygen -t rsa -C "admin@example.com"

注意,有提示直接敲回车,不要设置密码

将 ~/.ssh 的公钥 添加到gitlab ssh密钥设置

在这里插入图片描述


以上设置完毕后再本地项目文件里面创建本地仓库

  1. 在本地创建项目的文件夹
mkdir toutiao-backen
  1. 到项目目录下
cd toutiao-backen
  1. 创建本地仓库
git init
  1. Git 全局配置和添加remote origin
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
git remote add git@gitlab.example.com:root/toutiao.git
  1. 拉取代码
git pull origin master


如果想要通过https 方式拉去代码的情况需要在域名后面加端口号

例如:

git remote add origin http://gitlab.example.com:7080/root/toutiao.git

不加端口号会出现以下报错

在这里插入图片描述



以上内容参考

https://developer.aliyun.com/article/332654?spm=a2c6h.17698244.wenzhang.1.44693dfdxT7P7T

https://blog.csdn.net/u014451100/article/details/91816014

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值