I have 2 branches, master and featureA. In the featureA branch I have written a bunch of new code in CoolFile.m . The feature isn’t done so this code is not yet ready to be merged into master.
CoolFile was really poorly written in the past so in the develop branch I commited a bunch of changes to it (mostly reordering methods, adding comments, and deleting whitespace).
Now I want rebase featureA off of master so that I can benefit from the cleaned up code. The problem is that since all the methods have moved around, the rebase is trying to put all the new code in the wrong places. What’s the best way to fix this? Should I have just waited until the feature was done to refactor?
You could merge the changes from the master branch into your featureA branch,
Lets assume you created featureA from commit B on master, and that C, D and E are commits made on featureA and F and G are the commits that reordered the methods etc. What you want to do now, is to merge F and G into the featureA branch.
Or, you could cherry pick the commits F and G into featureA. Remember that you will still get conflicts and that these are just alternatives to your rebase option.
In the future I’d recommend that you do the refactoring either directly on featureA, or from another branch, branching off from featureA:
Then it’s a piece of cake to merge in the refactoring branch into featureA, since the merge would be trivial.