|
Git tries its best to merge everything automatically, but let's talk about why a merge conflict happens. Basically if more than one branch edits the same part of the base code, it cannot figure out what to do, and tells you, the user, to resolve it. In other words, there cannot be a "rule of thumb" for merge conflicts because if there was, the computer would have just done it automatically. Every situation is a little different and requires you to look at the actual contents of the conflicting code before making an informed decision.
Sometimes just replacing the old code with new one works. Other times, you can just include both, like if two different branches added new sprites and there's a conflict where they both defined those files in the code. Most of the time, however, you will need to intelligently combine the two snippets of code. Take a look at the two individual snippets. What are they each trying to accomplish? A lot of the functions have names. Do you generally know what is happening in the place you are trying to merge? What is the new code doing that the old code isn't? What is the old code doing that the new code isn't? Where are they differing? Does it just look like a function got renamed, or is the actual flow of the code different?
It cannot be avoided. You have to ask yourself these questions in order to solve merge conflicts. You don't need to know the exact details of the entire code, but enough that you can generally understand the pieces of the puzzle. The pret discord is there to help with these sort of things. While learning C will definitely help, it goes beyond that. Merge conflicts are a thing in pretty much every programming language in existence. It's more about understanding why the two pieces of code are incompatible with each other, and what you need to do to make a single, merged function to where they both work.
So unfortunately, there is no generalized solution for merge conflicts, simply because the very nature of a merge conflict is that it couldn't be solved automatically. You need to understand the code in order to be able to merge it.
__________________
Binary is dead.
|