-1

I have a feature branch called feature/a off of develop that was created a while ago. I have since merged feature/b and feature/c to develop. All of these branches have a common main file that they alter. I am now wanting to merge the develop branch into my feature/a branch to get all of the updated features/files. However, when I do this I lose some lines of code in the merge-conflicted main file.

For instance, I have the following block in develop/main but not in feature/b/main:

component module_a is
   generic 
   (
      MODULE_NAME : string
   ); 
   port 
   (
      clock : in std_logic;
      reset : in std_logic
   );
end component module_a;

However, when I go to merge develop into feature/a I only get the following line in the merge-conflicted main file:

component module_b is
...
...
<PORTS HERE>
...
...
<<<<<<< HEAD
end component module_b;
=======
end component module_a;
>>>>>>> develop

This merge-conflicted file drops the whole module declaration except for the end component module_a line. What could be the cause of this?

  • Set `merge.conflictStyle` to `diff3` so that you can see the merge base version, and/or use `git mergetool` or similar so that you can see all three versions. – torek Aug 25 '22 at 01:22

1 Answers1

0

Since you are merging develop into feature_a, these are the only two branches that matter as far as the merge conflict goes. The other feature branches help give some context about how you got here and might help to understand how you got into this state, but otherwise aren't helpful.

I suspect that the module declaration you think is missing is actually above the <<<<<<< HEAD because it doesn't cause any conflicts. You just need to edit the file to contain the code in the state you want it to be in.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • The module declaration is not above the `<<<<<<< HEAD` unfortunately. The only remnants of `module_a` are in the single line `end component module_a`. – user19840507 Aug 24 '22 at 19:06
  • @user19840507 From what I can tell, you'll have to edit the file to be the way you want and then commit it. If you still need help, edit your question to show us what the contents of `develop/main` and `feature/a/main` are. The other feature branches no longer matter here. – Code-Apprentice Aug 24 '22 at 19:09
  • Yes, it seems like I will have to manually edit the file but isn't the merge supposed to take care of the differences between the files? I understand the other branches do not matter for the merge but I just wanted to give a some background. These are completely different modules with different ports. There are no similar lines between the two. I do not understand why `module_a` is not being inserted into the merge-conflicted file at all expect for the single line listed above. – user19840507 Aug 24 '22 at 19:13
  • Automatic merging can't always resolve the differences on its own. When that happens, it lets you know and pauses the merge so that you can step in and fix the problem. Once you do that, you can continue the merge (`git merge --continue`). – Caleb Aug 24 '22 at 19:22
  • So it seems like the best solution is just to go in a manually add in the `module_a` instantiation, correct? I'm just surprised that it is not even showing the module declaration as a confliction between the two branches. – user19840507 Aug 24 '22 at 19:27
  • @user19840507 Yes, you will have to manually edit to include both modules. The conflict is likely because you edited the same lines in the `main` file. For example, if you edited lines 10-20 to add module_b then you edited lines 5-15 to add module_a, there is a conflict because overlapping sequence of lines were edited on both branches. – Code-Apprentice Aug 24 '22 at 20:13
  • @user19840507 I also suggest using a 3-way diff tool for resolving merge conflicts rather than editing the file directly. These give a visual representation of the version of the file on both branch as well as the version of the file you want to keep. – Code-Apprentice Aug 24 '22 at 20:15