-1

I've got 2 branches I would like to merge: main and sub. In both branches there is a file called Math.java. This class contains one function on both branches: addition() on main and subtraktion() on sub. When I type in git diff into the console it shows all the differences:

diff command in console

But when I run the git merge command, it only shows one difference in the Math.java file, like this:

<<<<<<< HEAD
        System.out.println("Summand 1: ");
=======
        
        System.out.println("Minuend: ");
>>>>>>>

Why is merge only detecting one different line of code and not the others like with the diff command? I would like to have all differences in the Math.java after the merge command.

How do I get that?

I deleted the files and copied them again into the directories, but that didn't change anything.

3
  • stackoverflow.com/questions/14961255/what-is-git-merge-doing Commented Apr 24, 2024 at 13:07
  • 1
    the java tag is not really relevant for this question Commented Apr 24, 2024 at 13:15
  • Those are merge conflict markers. It seems that you do not know what merge is or what a merge conflict is. If there had not been that one conflict, the merge would not have inserted any conflict markers; it would have just done the merge, kaboom. Perhaps you would be helped by reading my biteinteractive.com/understanding-git-merge Commented Apr 24, 2024 at 13:20

1 Answer 1

1

Is it possible that git merge automatically merged the non-conflicting changes? So this single line is just what could not be automatically merged?

Sign up to request clarification or add additional context in comments.

3 Comments

That would mean, that merge overwrites all different lines of code, except one. That would be really weird behaviour.
It does not overwrite... it just mixes the changes coming from each brach.... the other sections were mixed without issues.... the same way a person who does not code would do if they saw the java files as text.
Are you merging a single commit? Or multiple commits?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.