I don't understand in what condition do git consider there are conflicts when merging two local branches.
When I create a file a.py in branch test1, then merge it to another branch test2, and then make some modifications, the merge process seems all smooth and do not report conflicts.
But when I create a file a.py in branch test1 and create another file with the same name a.py in branch test2. Every time I try to merge two files, git report me a conflict.
Second day using git, I just don't know how merge works, chatGPT told me that when one file in two branch is modified differently at same lines. But what make me confused are:
in my case, I only delete one line, the git diff output is :
diff --git a/c.py b/c.py index f2db9da..b917a72 100644 --- a/c.py +++ b/c.py @@ -1,2 +1 @@ print(1) -print(2)
2. If all content are to be compared line by line, then when I type a break line in the middle of a file, then the rest of the file will no longer be recognized as the same as other branches since the lines are all shifted. So what's the point doing such overly rigorous check?
3. Or if git can think like "he just added one break line so let's just sync that to another branch". And how could git be able to do this? Suppose it can actually do this, when I delete from the middle of the file to the end and then paste it back, does git think I delete and add something? or it just think nothing really happened. If the second one, then it seems still do the line-comparing, and then this question just turn back to my no.2 question. If the first one, the conflict are just more serious because half of the file need to review manually, though they are identical.
If I'm wrong, I really apologize for that, because I just learned the basic git usage yesterday, and stuck in the merge stuff. I would appreciate that if you can elaborate the situation for me, thank you guys so much!
print(1)toprint(3)and the other side removed the lineprint(1), that would be a conflict.chatGPT told me. All such machine generated response systems are notorious serial liers. It represents absolutely no authority whatsoever and its replies should be regarded with the highest degree of scepticism. Only use it as input to what to search for with normal web search engines.