1

I've got problem with GIT. I've got following situation:

       -> M1 -> M2 -> ............. Ma -> Mb -> Mc            [master]
          \                                \
           \                                \ (merge 'master' to 'merge_branch' without commit 'Mc')
            \ (create branch 'develop')      \
             \                               /-> A -> A1      [merge_branch]
              \                             /
               \                           / (create branch 'merge_branch' from 'develop' at 'Da')
                \                         /
                 \ -> D1 -> ...........-> Da -> Db           [develop]

And I want to rebase branch 'merge_branch' (to start it from commit 'Db' instead of 'Da')

       -> M1 -> M2 -> ................... Ma -> Mb -> Mc            [master]
          \                                       \
           \                                       \ (merge 'master' to 'merge_branch' without commit 'Mc')
            \ (create branch 'develop')             \
             \                                      /-> A -> A1      [merge_branch]
              \                                    /
               \                                  / (create branch 'merge_branch' from 'develop' at 'Da')
                \                                /
                 \ -> D1 -> ...........-> Da -> Db           [develop]

On master branch there are a lot of commits (thousands). When I am on 'merge_branch' and start rebase 'git rebase develop', I am receiving plenty of conflicts.

I usually created a new branch, did a merge again, but I had to resolve the same merge conflicts as were resolved previously. It was much faster than rebasing branch, but also very slow...

Do you have any ideas how to solve this problem?

iblis
  • 181
  • 2
  • 9
  • 1
    Where the branches point is unclear to me from your diagrams. Could you format it like [this](https://stackoverflow.com/questions/26024586/how-can-i-merge-a-branch-into-master-but-continue-working-on-the-branch/26024880#26024880) instead? – jub0bs Sep 27 '18 at 19:39

1 Answers1

0

I think the issue here is that you create a merge_branch from develop, which is too ahead of master. In your situation, you should branch this merge_branch from your master:

git checkout master

# branch out from master and checkout, now you are on merge_branch
git checkout -b merge_branch   

# force delete Mc on merge_branch
git reset --hard Mb  

# attempt to merge with develop to catch up
git pull --rebase origin develop   

Depends on how in-sync between your develop and master, you might still run into a lot of merge conflicts though. But you should not run into repetitive conflicts since you are merge a 'faster' branch into a 'slower' branch.

congbaoguier
  • 985
  • 4
  • 20