Git rebase after a lot of refactoring

I have 2 branches, master and featureA. In the featureI branch, I wrote a bunch of new code in CoolFile.m. The function has not completed, so this code is not yet ready to be merged with the wizard. CoolFile was really poorly written in the past, so in the development branch I made a bunch of changes to it (mostly by reordering methods, adding comments and removing spaces).

Now I want the forwarding feature to disconnect from the wizard so that I can benefit from the cleared code. The problem is that since all methods move, rebase tries to put all the new code in the wrong places. What is the best way to fix this? Should I just wait until the function is executed for refactoring?

+3
source share
2 answers

You can merge the changes with the main branch into the branch of your function,

A--B--F--G--H master
   \
    \-C--D--E featureA

Suppose you created featureA from commit B to master, and that C, D and E are commits made on featureA, and F and G are commits that reorder methods, etc. Now you want to merge F and G into the feature branch.

$ git checkout featureA
$ git merge G (G is the sha1)

Or, you could cherry pick commits F and G in featureA. Remember that you will run into conflicts anyway and that this is just an alternative to your rebase option.

In the future, I would recommend that you do refactoring either directly on featureA or from another branch, separate from featureA:

A--B--F--G--H master
   \
    \-C--D--E featureA
         \
          \-I--J--K refactorFeatureA

Then this is a piece of cake to join in a refactoring branch in featureA, since merging would be trivial.

+1
source

, - git newb, ( ), , , ( , , , ). , .

, - . , , .

, /. x , , . - , , .

+1

All Articles