Scribing vs. rebasing

Below is the scenario that I usually come across:

You have a set of commits on master or design that I want to place on top of the production branch.

I try to create a new branch with the base as production cherry-pick, this will commit to it and merge it into production

Then, when I combine master with production, I encounter merge conflicts because even the changes are the same, but are registered as different commits due to the cherry pick.

I found some workarounds to handle this, all of which are labor intensive and can be called "hacks."

Altho 'I do not reinstall too much, I believe that also creates a new commit hash.

Should I use reboot where I am a shred. What other benefits does this have.

+3
git git-rebase rebase cherry-pick
Jun 11 2018-10-11
source share
1 answer

You have to rebase --interactive your design branch on top of production, where:

  • You can change the order of your commits, starting with the ones you need in production.
  • you can combine production with the last design fixation you want to enable (fast forward).
     -x - x - x1 - x - x2 (design)
       \
        p - p (production)

With x1 and x2, which must be included in the production:

 git checkout design git rebase --interactive production -x \ p--p (production) \ x1'-x2'--x'--x' (design) 

Then:

 git checkout production git merge x2' -x \ p--p--x1'--x2' (production) \ x'--x' (design) 

This allows:

  • to check the current project, undertakes to make compromises (durung the rebase)
  • reorder
  • include first in production
  • allows subsequent mergers from design to production to be fast-acting.



Lakshman Prasad adds:

I push the changes the most at the end of the day. So it doesn’t help much. How your answer will change for the pressed main branch

I would do the same, but with a private branch created only for the operation:

 git checkout master git checkout -b master-private 
     -x - x - x1 - x - x2 (master, master-private)
       \
        p - p (production)

then rebase, this time with a private branch (i.e. a branch that you will never push).

 git rebase --interactive production -x--x--x1--x--x2 (master) \ p--p (production) \ x1'-x2'--x'--x' (master-private) 

Then:

 git checkout production git merge x2' -x--x--x1--x--x2 (master) \ p--p--x1'--x2' (production) \ x'--x' (master-private) 

master will not benefit from reordering the commit (in a more logical order), but at least you can press master whenever you want.

And production may still include exactly what it needs.
If the subsequent master commit has the same problem (some should be included in production , others later), I would:

  • delete master-private (we don’t really care about those x ', a copy of x is committed from the master)
  • make the master-private branch on top of the master
  • repeat the rebase --interactive operation with conflict resolution tactics (except for the first commits of this master-private branch, since they must be integrated into the production branch)
     -x - x - x1 - x - x2 - x - x3 - x (master)
       \
        p - p - x1 '- x2' - x3 '(production)
                    |  \
                    |  x '' - x '' (master-private)
                     \
                      x '.. x' (old x 'from the first master-private)
+3
Jun 11 '10 at 11:52
source share



All Articles