迁移git仓库某分支到另一个仓库某分支

当前仓库地址为:

[email protected]:one-ios/UnifyPassportService.git

待迁移分支为:

global_release_20210916_nationalTick

目的仓库地址为:

[email protected]:global/UnifyPassportService.git

目的分支为:

global_release_20211028_nationalTick

步骤:

cd到.git目录下并checkout到old分支global_release_20210916_nationalTick执行:

1》git remote add global [email protected]:global/UnifyPassportService.git

2》git checkout -b global_release_20211028_nationalTick

3》git push global global_release_20211028_nationalTick

命令行打印信息如下:

Total 0 (delta 0), reused 0 (delta 0), pack-reused 0

remote:

remote: [code_review]

remote: run code review post hook success

remote: To create a merge request for global_release_20211028_nationalTick, visit:

remote:   http://git.mama.com/global/UnifyPassportService/merge_requests/new?merge_request%5Bsource_branch%5D=global_release_20211028_nationalTick

remote:

To git.mama.com:global/UnifyPassportService.git

* [new branch]        global_release_20211028_nationalTick -> global_release_20211028_nationalTick

4》cd 到新仓库的本地.git目录的任意分支例如master,执行

git pull origin master 会拉取到远程分支 global_release_20211028_nationalTick

结果

1》用上述方法迁移过来的分支依旧保持了原先的commit记录;

2》本次操作为迁移不同名分支

(旧分支名为:global_release_20210916_nationalTick;新分支名为:global_release_20211028_nationalTick)

参考:https://segmentfault.com/a/1190000040311925

迁移整个仓库并保留commit记录(to try):git仓库迁移的两种解决方案 - ZhangRuoxu - 博客园

git迁移版本分支及提交记录的一个方案 - 你好啊,再见了 - 博客园

TODO:迁移同名分支并保留commit记录;迁移整个仓库并保留commit记录;fork仓库

你可能感兴趣的:(ios,版本管理,git,github)