Chetan Zade
Chetan Zade

Reputation: 29

Git merge overwrites rather than giving conflicts

I'm trying to merge two repositories. But whenever I merge, it should give conflict in sample.txt file rather that overwriting the same. Steps followed are in attached image.Git version is : 2.7.4 Is the process right? if yes, the why don't I get conflicts?

repro

Full-size image here.

Upvotes: 0

Views: 180

Answers (1)

zoul
zoul

Reputation: 104115

This is the expected behaviour, this use case should not lead to a conflict. There is no “real” merging done, since the changes from the branch can be simply applied to master as if the other branch never existed (this is called a “fast-forward merge”). Before merge:

--A--B <-- master
      \
       C--D <-- branch

After merge:

--A--B--C--D <-- master

If you wanted to see a conflict, you would have to create a history like this:

--A--B--D <-- master
      \
       C--E <-- branch

Now if the commit D “touches the same lines” as C and E, there could be a conflict when you try to merge back to master.

Upvotes: 2

Related Questions