Feels like I should refresh a bit my knowledge of git.
Say, I have branch with commit A1 A2 .. AM .. AN, where AM is pretty far from AN (after AM there had been a lot of, hundreds, actually other commits, including merges).
Some branch B had been checked out from AM, so this branch looks like AM B1 B2 B3 B4 …
Now I want to merge B back to A and, just as expected, get a lot of different CONFLICTS.
What is not expected, almost all of this conflicts are related to files I haven’t touched in branch B at all.
I can only assume that all these conflicts are due to the fact that AM is quite old branch.
My question is: what is the best way to merge B to A? The best strategy I can think of is to create a branch A1 A2 …. AM B1 B2 …. AN and try to merge this back to A1 … AN. How can I achieve this? Should I even try to? May be in my understanding of how git merges are done I am missing something fundamental?
Really, you need to identify and understand those conflicts. This isn’t a process issue, something is wrong in your tree. If, as you assert, “AM” is an ancestor of HEAD on both branches, and commits “AM..AN” do not touch files modified in “B1..B4”, then you should not get conflicts on those files, period. The fact that you are implies that you are mistaken about the state of your tree, probably because there are merge commits in there that have modified the files, or because a rebase was done such that “AM” (the actual commit, not just another commit with the same message) is not actually a shared ancestor of both branches.