I have two branches I wanna merge them into each other but the problem is that one of them stopped taking any update from the other months ago. So, when I try to merge them I get a large number of complicated conflicts.
Is there any solution to merge them safely?
Note: I’m using Android Studio
>Solution :
There is no way around this…. conflicts happen because code went in different directions and so they have to dealt with. One way you could turn a big pile of conflicts to be dealt with in a single shot could be to rebase the longer branch (since they diverged) onto each one of the commits of the shorter branch. Say…. you have these two branches
A <- B <- C <- D <- E <- (branch1)
^
\- F <- G <- (branch2)
You could run git switch branch2; git rebase C. You might get smaller conflicts, and end up with this:
A <- B <- C <- D <- E <- (branch1)
^
\- F' <- G' <- (branch2)
Then git rebase D, and end up with this:
A <- B <- C <- D <- E <- (branch1)
^
\- F'' <- G'' <- (branch2)
And finally git rebase branch1 and end up with this:
A <- B <- C <- D <- E <- (branch1)
^
\- F''' <- G''' <- (branch2)
But this does not mean you will avoid conflicts….. you could actually get more conflicts along the way, but they should theoretically be smaller (that might actually not be the case, but alas, it’s impossible to know beforehand).