Gitlab/GitHub:迁移代码,并保留历史记录

简介: Gitlab/GitHub:迁移代码,并保留历史记录

目录

1. 需求

2. 实现

第1步:从原地址克隆一份裸版本库

git clone  --bare 解释

第2步: 以镜像推送的方式上传代码

git push --mirror 解释



1. 需求

Git仓库地址改变,需要代码迁移,但需要保留之前开发人员的提交记录,方便回溯


2. 实现

第1步:从原地址克隆一份裸版本库

WANGYANFEI+Administrator@wangyanfei MINGW64 /d/JT/java/back
// 克隆一份裸版本库
$ git clone  --bare http://XX.XX.XX.XX/wangyanfei/certificate-end.git
Cloning into bare repository 'certificate-end.git'...
remote:                                                                                                                                                                                                                                                                        remote: Enumerating objects: 1249, done.
remote:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     remote: Counting objects: 100% (1249/1249), done.                                                                                                                                                                                                                                                                       remote:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                remote: Compressing objects: 100% (673/673), done.
remote: Total 1249 (delta 364), reused 1050 (delta 253)
Receiving objects: 100% (1249/1249), 321.04 KiB | 0 bytes/s, done.
Resolving deltas: 100% (364/364), done.

git clone  --bare 生成的文件夹名称会多出一个.git


git clone  --bare 解释

--bare

Make a bare Git repository. That is, instead of creating <directory> and placing the administrative files in <directory>/.git, make the <directory> itself the $GIT_DIR.

This obviously implies the -n because there is nowhere to check out the working tree.

Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/.

When this option is used, neither remote-tracking branches nor the related configuration variables are created.

第2步: 以镜像推送的方式上传代码

新的项目仓库需要建好

WANGYANFEI+Administrator@wangyanfei MINGW64 /d/JT/java/back/certificate-end.git                                                                                                                                                                                                (BARE:master)
// 以镜像推送的方式上传代码
$ git push --mirror http://10.0.0.247/jiean/certificate-end.git
Counting objects: 1249, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (562/562), done.
Writing objects: 100% (1249/1249), 321.01 KiB | 0 bytes/s, done.
Total 1249 (delta 364), reused 1249 (delta 364)
remote:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                remote:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              remote: Resolving deltas: 100% (364/364), done.
remote:
remote: To create a merge request for develop, visit:
remote:   http://10.0.0.247/jiean/certificate-end/merge_requests/new?merge_reque                                                                                                                                                                                               st%5Bsource_branch%5D=develop
remote:
remote: To create a merge request for release, visit:
remote:   http://10.0.0.247/jiean/certificate-end/merge_requests/new?merge_reque                                                                                                                                                                                               st%5Bsource_branch%5D=release
remote:
To http://10.0.0.247/jiean/certificate-end.git
 * [new branch]      develop -> develop
 * [new branch]      master -> master
 * [new branch]      release -> release
 * [new tag]         zsquery-v1.0-20200825 -> zsquery-v1.0-20200825


git push --mirror 解释

--mirror

Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository.

Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end.

This is the default if the configuration option remote.<remote>.mirror is set.



目录
相关文章
|
1月前
|
Java Serverless 项目管理
云效常见问题之自建gitlab代码同步到codeup报通过token访问失败如何解决
云效(CloudEfficiency)是阿里云提供的一套软件研发效能平台,旨在通过工程效能、项目管理、质量保障等工具与服务,帮助企业提高软件研发的效率和质量。本合集是云效使用中可能遇到的一些常见问题及其答案的汇总。
41 1
|
2月前
gitlab迁移后报错OpenL::cipher::CipherError
gitlab迁移后报错OpenL::cipher::CipherError
112 0
|
3月前
|
开发工具 数据安全/隐私保护 git
如何提交代码到github
如何提交代码到github
|
2月前
|
人工智能 运维 Linux
一文了解IntelliJ IDEA如何使用git上传代码到GitHub(附常见问题解决方案)
一文了解IntelliJ IDEA如何使用git上传代码到GitHub(附常见问题解决方案)
92 0
|
2天前
|
Linux 网络安全 开发工具
【超详细!超多图!】【代码管理】Python微信公众号开发(3)- 服务器代码上传Github
【超详细!超多图!】【代码管理】Python微信公众号开发(3)- 服务器代码上传Github
10 0
|
4天前
|
运维 Devops Shell
云效产品使用报错问题之在codeup上创建的代码分支或者代码变动,同步到gitlab失败如何解决
本合集将整理呈现用户在使用过程中遇到的报错及其对应的解决办法,包括但不限于账户权限设置错误、项目配置不正确、代码提交冲突、构建任务执行失败、测试环境异常、需求流转阻塞等问题。阿里云云效是一站式企业级研发协同和DevOps平台,为企业提供从需求规划、开发、测试、发布到运维、运营的全流程端到端服务和工具支撑,致力于提升企业的研发效能和创新能力。
|
4月前
|
开发工具 git Windows
Git | 向GitHub提交代码超时处理
向GitHub提交代码超时处理
113 0
|
1月前
|
JavaScript Go 项目管理
云效常见问题之使用gitlab仓库将代码合并评审环节集成到云效如何解决
云效(CloudEfficiency)是阿里云提供的一套软件研发效能平台,旨在通过工程效能、项目管理、质量保障等工具与服务,帮助企业提高软件研发的效率和质量。本合集是云效使用中可能遇到的一些常见问题及其答案的汇总。
97 1
|
2月前
|
安全 Shell 网络安全
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
131 0
|
3月前
|
语音技术
如何在GitHub正确提PR(Pull Requests),给喜欢的开源项目贡献代码
最好的中文TTS项目Bert-vits2更新了中文特化分支,但可能由于时间仓促,代码中存在不少的bug,作为普通用户,有的时候也想为自己喜欢的开源项目做一点点贡献,帮助作者修改一些简单的bug,那么该如何开始? 本次我们以Bert-vits2项目为例子,分享正确提交PR(Pull Requests)的方式。