views:

180

answers:

1

Background: I've inherited some MATLAB code to analyze data for my Ph.D. research. To help me better understand the code, I've pared the code down to the minimum subset of files required to run the code for a sample test case.

Question: I would like to commit this code to a version control system as two branches, a master branch containing all of the code, and a minimal branch containing my pared-down version of the code, and be able to merge changes back and forth between these branches. How can I accomplish this?

I would prefer to do this with a single working directory and named branches in either Git or Mercurial, but I am open to other suggestions.

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.

+3  A: 

Both git and mercurial should work fine. Create the master branch, then copy it to the minimal branch, then strip the minimal branch to look like the implementation you already have (delete all extra files, copy over the files that you have changed).

From then on, use regular merging commands between the branches. It's probably best to merge from the minimal branch to the master branch primarily. Merging the other way 'round more likely gives you complaints that the merging failed (with conflicts) as some of the files apply to deleted files/removed functions.

Martin v. Löwis
Note that you can also make two initial commits in a single repository, which will save you having a commit which deletes a large number of files, but on the flip side have redundant information between your initial commits.
Jefromi