[英]How to migrate from one Git repo to another Git repo?
我需要从一个 Git 存储库迁移到另一个 Git 存储库。 目的地不为空。 过去有人显然已经做了这项工作,但现在所有的分支都已经过时了。
这是这种情况:
源远程存储库: repo_source
分支机构:
目标远程存储库: repo_dest
分支:
这个想法是让缺失的分支(branch_C,branch_D)和已经存在的分支(branch_A,branch_B)需要用新数据进行更新。
例如这里只有 4 个分支,但实际上更多。 那么,有没有一种方法(脚本)可以使这种迁移变得简单?
使用 git 克隆命令克隆存储库 repo_source。
git clone repo_source
一旦完成,
git remote add repo_dest repo_dest_url
git push --force --all repo_dest
即使存在,这也应该替换所有目标分支。
您可以将repo_dest
存储库添加为另一个远程存储库,然后在本地提取和合并更改并推送它们。
从您的本地工作目录尝试以下操作;
git remote add new_origin ORIGIN_URL # add new remote
git pull new_origin branch_A # pull, merge branch_A and fix conflicts (if any)
git pull new_origin branch_B # pull, merge branch_B and fix conflicts (if any)
git push new_origin branch_A # push each branch to the new remote
git push new_origin branch_B
git push new_origin branch_C
git push new_origin branch_D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.