其他分享
首页 > 其他分享> > GitLab仓库迁移

GitLab仓库迁移

作者:互联网

概述

实战

GitLab仓库地址从http://192.168.20.149:8090/迁移到http://192.168.0.149:8090/。背景知识:项目信息在.git/config文件有所显示。先查看一下原始.git/config文件:

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[remote "origin"]
	url = http://192.168.20.149:8090/zhsh/arm.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
[branch "dev"]
	remote = origin
	merge = refs/heads/dev

首先将原来的origin重命名一下:
git remote rename origin origin1

再指定需要迁移到的目标地址:
git remote add origin http://192.168.0.149:8090/zhsh/file-center.git

上传到新服务器:
git push origin --all

这一步,需要先在GitLab Web端创建一下Group,否则报错:

libpng warning: iCCP: cHRM chunk does not match sRGB
remote: The project you were looking for could not be found.
fatal: repository 'http://192.168.0.149:8090/zhsh/file-center.git/' not found

git push origin --all重试,成功。去GitLab Web端看一下项目信息:
在这里插入图片描述
commit提交记录都有保留,目的达到。

再来看看.git/config文件,已经更新为:

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[remote "origin1"]
	url = http://192.168.20.149:8090/zhsh/file-center.git
	fetch = +refs/heads/*:refs/remotes/origin1/*
[branch "master"]
	remote = origin1
	merge = refs/heads/master
[branch "dev"]
	remote = origin1
	merge = refs/heads/dev
[remote "origin"]
	url = http://192.168.0.149:8090/zhsh/file-center.git
	fetch = +refs/heads/*:refs/remotes/origin/*

可见该项目有两个远程origin,故而猜测以后在push代码时,需要指定push到哪个服务器,验证一下:
在这里插入图片描述
光标一直在闪烁,提示选择一个远程origin。

如果旧的origin,即上面重命名的origin1不再需要,可以直接修改.git/config文件,删除origin1相关信息。这样就可以避免选择origin。

参考

标签:origin,git,remote,8090,仓库,refs,GitLab,192.168,迁移
来源: https://blog.csdn.net/lonelymanontheway/article/details/118104475