简体   繁体   English

GIT rebase合并分支

[英]GIT rebase merge branch

I've got problem with GIT. 我有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') 我想重新设置分支“ merge_branch”(从提交“ Db”而不是“ 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). 在master分支上有很多提交(千)。 When I am on 'merge_branch' and start rebase 'git rebase develop', I am receiving plenty of conflicts. 当我在'merge_branch'上并开始重新设置'git rebase development'时,我收到很多冲突。

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? 您是否有解决此问题的想法?

I think the issue here is that you create a merge_branch from develop, which is too ahead of master. 我认为这里的问题是,您通过development创建了merge_branch,这比master提前。 In your situation, you should branch this merge_branch from your master: 根据您的情况,您应该从主服务器分支此merge_branch:

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. 但是,您不应将重复的冲突合并到“较慢的”分支中,因此,您不应遇到重复的冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM