git - 复制一个 git 存储库并分成两部分
问题描述
我的团队目前使用一个 TFS Git 存储库来进行开发(网络/移动)和测试(小黄瓜规范 + 自动化代码)。
开发团队“遵循” git flow 分支约定,但测试团队使用完全不同的分支(它们永远不会重新设置或与 feature/develop/rc/master 或我们的任何开发分支合并),所以我们想拆分存储库,保持历史记录和分支原样。
我尝试了将远程 URL 更改为新的 TFS Git 存储库并推送的第一个选项。但这只会推动我当前的分支。所以我尝试了第二个选项
git clone --mirror current_repo_url
git push --mirror new_repo_url
一切看起来都一样,我有整个历史。但是现在我读到 SO 上的其他人正在使用 git filter-branch 和其他“复杂”命令执行此操作,是否需要?和我做的镜子有什么区别?“镜像”是否意味着这些存储库将永远同步并且不能独立更改?
稍后我们将使用该测试 repo 作为 dev repo 的子模块,每个团队将清理其未使用的分支,但现在我们只想要无忧的迁移(基本上更改 remote-url 就是这样),所以我做的很好?
编辑 :
我没有注意到它,但是 push --mirror 最后返回了以下错误,知道这些参考是什么吗?
! [remote rejected] refs/pull/2616/merge -> refs/pull/2616/merge (The current action can only be performed by the system.)
! [remote rejected] refs/pull/2625/merge -> refs/pull/2625/merge (The current action can only be performed by the system.)
! [remote rejected] refs/pull/2655/merge -> refs/pull/2655/merge (The current action can only be performed by the system.)
! [remote rejected] refs/pull/2668/merge -> refs/pull/2668/merge (The current action can only be performed by the system.)
解决方案
...我们想拆分存储库,保持历史记录和分支不变。
您所做的将起作用,并且没有问题。
其他选项:
filter-branch
如上所述,您还可以使用filter-branch
which 将导致变基,因为它将更新旧的提交
subtree split
# split the "main repo" into smaller repos
git subtree --split .... <branch1>
该git subtree --split .... <branch1>
命令将“提取”对给定文件夹所做的所有提交,并将它们放置在新分支中。分支将包含给定路径的所有内容。这也将导致变基,因为历史将被重写
推荐阅读
- rust - 从另一个模块打印 vec 中的值:结构的字段是私有的
- ios14 - 是否可以在没有完整应用程序的情况下构建 App Clip?
- r - 将时间序列分组为分层数据
- symfony5 - 在新用户的表单中使用密码编码器
- r - 在用户定义函数中调用 colnames()
- mysql - 如何只选择一个值的前 2 个寄存器?
- javascript - 如何解决这种意外混合的“>>>”和“&”运算符警告?
- c# - 列表
- > 达到内存限制
- cypress - 赛普拉斯:赛普拉斯无法找到边缘
- python - 在本地运行 Pyspark 以访问 S3 中的 parquet 文件错误:“无法从链中的任何提供商加载 AWS 凭证”