git - 维护开发分支,其中一个分支是另一个分支的子集

标签 git version-control mercurial branch subset

背景:我继承了一些 MATLAB 代码来分析我的博士学位。研究。为了帮助我更好地理解代码,我将代码缩减为运行样本测试用例代码所需的最小文件子集。

问题:我想将此代码作为两个分支提交到版本控制系统,一个包含所有代码的 master 分支,一个包含所有代码的 minimal 分支包含我的代码精简版本,并且能够在这些分支之间来回 merge 更改。我怎样才能做到这一点?

我更愿意在 Git 或 Mercurial 中使用单个工作目录和命名分支来执行此操作,但我愿意接受其他建议。

Edit: I thought I'd seen a previous Stack Overflow question along these lines, and I just found it: Pushing updates to a pruned Mercurial branch. In a comment to the accepted answer, it's mentioned that the term for what I'm trying to do is "narrow cloning" and that it's a work in progress for both Git and Mercurial.

最佳答案

git 和 mercurial 都应该可以正常工作。创建主分支,然后将其复制到最小分支,然后剥离最小分支以看起来像您已经拥有的实现(删除所有额外文件,复制您已更改的文件)。

从那时起,在分支之间使用常规的 merge 命令。最好主要从最小分支 merge 到主分支。以另一种方式 merge 更有可能让您提示 merge 失败(有冲突),因为某些文件适用于已删除的文件/已删除的功能。

关于git - 维护开发分支,其中一个分支是另一个分支的子集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1343802/

相关文章:

python - 同一个类中的同名函数 - 有没有一种优雅的方法来确定调用哪个?

version-control - Mercurial 无法识别存储库中的新文件夹

git - 为什么在创建分支时git无法识别我?

git - 批量重命名 Git 作者?

java - 为什么我在推送到 Git Android Studio 时出错?

mercurial - 在两个单独的 Mercurial 存储库之间拉取更改

mercurial - 将子存储库与 bitbucket 一起使用

Visual Studio 上的 GIT 远程扩展 - 显示大量未知更改

git - 执行多个 git 远程推送的正确过程

eclipse - Eclipse 中带有 mercurial 的红色感叹号