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.



相关文章
|
3月前
|
人工智能 自然语言处理 安全
Milvus x n8n :自动化拆解Github文档,零代码构建领域知识智能问答
本文介绍了在构建特定技术领域问答机器人时面临的四大挑战:知识滞后性、信息幻觉、领域术语理解不足和知识库维护成本高。通过结合Milvus向量数据库和n8n低代码平台,提出了一种高效的解决方案。该方案利用Milvus的高性能向量检索和n8n的工作流编排能力,构建了一个可自动更新、精准回答技术问题的智能问答系统,并介绍了部署过程中的可观测性和安全性实现方法。
|
3月前
|
存储 人工智能 自然语言处理
让你拥有一个AI大脑,这个32.1k Github项目是你不错的选择,支持PDF、Markdown、代码、视频成为你的知识内容
Quivr 是开源全栈 RAG 平台,助你打造“第二大脑”,支持多文档类型与多种 LLM,实现智能搜索与聊天。具备语义检索、本地部署、隐私保护等功能,适用于个人知识管理与企业知识库,界面简洁易用,是高效智能问答的理想选择。
175 0
|
6月前
|
JSON JavaScript API
MCP 实战:用配置与真实代码玩转 GitHub 集成
MCP 实战:用配置与真实代码玩转 GitHub 集成
1382 4
|
8月前
|
人工智能 网络安全 开发工具
vscode代码推送到github库菜鸡专用教程
vscode代码推送到github库菜鸡专用教程
|
10月前
|
Devops Shell 网络安全
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
414 16
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
|
运维 Java Devops
阿里云云效操作报错合集之在进行GitLab代码分支迁移时遇到报错,一般是什么原因
本合集将整理呈现用户在使用过程中遇到的报错及其对应的解决办法,包括但不限于账户权限设置错误、项目配置不正确、代码提交冲突、构建任务执行失败、测试环境异常、需求流转阻塞等问题。阿里云云效是一站式企业级研发协同和DevOps平台,为企业提供从需求规划、开发、测试、发布到运维、运营的全流程端到端服务和工具支撑,致力于提升企业的研发效能和创新能力。
|
10月前
|
自然语言处理 安全 Devops
GitLab 国际站中国大陆等地区停服,如何将数据快速迁移到云效
对于正在使用 GitLab 国际站托管代码的企业和研发团队,除迁移至极狐 GitLab 外,国内其他主流的 DevOps 平台也具有完备的产品能力,为开发者提供了更多的选择。其中,阿里云云效也提供了针对常见代码托管平台如 GitHub、GitLab 简单便捷的迁移方案,帮助用户快速完成核心代码数据的迁移,确保代码资产安全。
|
开发工具 git Python
代码管理记录(二):Github代码上传实操
本文是关于如何使用Git将本地代码上传到GitHub的实操指南。介绍了Git的基本概念、安装方法,并通过详细的步骤指导用户从GitHub创建仓库到使用Git命令初始化、添加、提交代码,最终将代码推送到远程仓库。同时,还汇总了一些常见的错误及其解决方法。
340 2
代码管理记录(二):Github代码上传实操
|
存储 安全 API
GitHub主要仓库泄露访问令牌,代码与云环境面临风险
GitHub主要仓库泄露访问令牌,代码与云环境面临风险
GitHub主要仓库泄露访问令牌,代码与云环境面临风险
|
安全 网络协议 Shell
Github代码仓库SSH配置流程
这篇文章是关于如何配置SSH以安全地连接到GitHub代码仓库的详细指南,包括使用一键脚本简化配置过程、生成SSH密钥对、添加密钥到SSH代理、将公钥添加到GitHub账户以及测试SSH连接的步骤。
622 0
Github代码仓库SSH配置流程