[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>背景
需求:将项目需要整体迁移至阿里云的codeup
<>现状
所有的项目都在自搭的gitlab服务器
<>流程
* 备份当前服务器中的项目代码(以免出错)
* 在新的gitlab或codeup或gitee中创建新的代码库
* 修改当前服务器中项目的远程仓库地址
* 将项目代码推送至远程仓库
<>1. 备份
比如项目名称为server,执行命令将项目进行打包备份
zip server.zip server/*
<>2. 创建新的代码仓库
此步骤前往对应的git仓库建立即可
<>3. 生成及添加git秘钥
先看是否已存在
cat ~/.ssh/id_rsa
不存在则执行该命令进行生成,
ssh-keygen -t rsa -b 4096 -C "邮箱地址"
若存在可在生成时自己定义生成的位置,以防被覆盖,在:处自定义位置及名称
Generating public/private rsa key pair. Enter file in which to save the key (
~/.ssh/id_rsa):
一路回车即可,默认位置在 ~/.ssh/ 下,将对应文件夹下的公钥文件上传至对应的git中
<>4. 服务器中的秘钥冲突
在服务器拉取代码时显示git秘钥冲突,可在.ssh文件夹中生成config文件,具体配置如下
# 账号A Host codeup_1 HostName codeup.aliyun.com IdentityFile ~/.ssh/codeup_1
PreferredAuthentications publickey User username1
* HostName:填写托管平台服务地址;
* Host:填写别名,方便命令行使用;
* IdentityFile:填写证书(秘钥)位置;
配置完成后使用该命令查看配置是否生效
ssh -t git@codeup_1
拉取代码时使用对应的host即可使用对应的秘钥,如:
git clone git@codeup_1:XXX.git
<>5. 修改项目远程地址
* 清除known_hosts对应的之前的地址,known_hosts作用为ssh会把每个你访问过计算机的公钥(publickey)都记录在known
hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告,避免你受到DNS
Hijack之类的攻击。所以需要清楚之前记录的信息,该文件在~/.ssh文件夹中,建议清楚前先做备份
* 进入项目中
2.1 查看当前项目远程仓库git remote -v 2.2 清除当前项目的远程仓库git remote remove origin 2.3
添加新的git远程仓库地址git remote add origin 地址
<>6. 将项目推送至远程仓库中
git push -u origin --all