Please explain. Why there is no conflict here: screen without conflict
and here it is: screen with conflict
Is there any way to avoid such conflicts? Thanks a lot for the answers.
Please explain. Why there is no conflict here: screen without conflict
and here it is: screen with conflict
Is there any way to avoid such conflicts? Thanks a lot for the answers.
Your question is strange because your are showing different things. But it shows that you didn't get something... because the answer is in the 2nd image: "file has been changed in source and destination".
The first image is the result of a change. (Side node: in the future, please include directly your image in your question)
The second image is a conflict occurring when you try to merge (or rebase) a commit.
and here it is: screen with conflict
In fact, this piece of code has been changed in the 2 branches you want to merge (or do something equivalent). So when git try to apply the patch on the file corresponding to the commit, it found that the line removed is not the one expected (sometimes it's even the context lines --the one above or below the change-- that just changed).
So the patch can't apply automatically (understanding patch file format here could help) and git ask you to solve the conflict i.e. decide which incompatibles changes you want to keep (or need your brain to merge the 2 changes).
Is there any way to avoid such conflicts?
There is no perfect way to avoid conflicts because that just means that 2 people worked on the same part of the file and so that a human have to make a choice.
One thing that you could sometimes do is to have the last version of the changes and do your changes after the other changes. That's more a team organization...
But when you work in branches that's not always possible.