背景:我继承了一些 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/