I want to simulate conflict in git while switching braches without committing.
I have a master branch where I have a few files which are committed.
I create anther branch and modify the files which are also present in the master branch.
I still have not committted changes in the other branch.
But when I try to checkout the master branch It allows me to do the same.
I have not been able to simulate a conflicting scenario.
Can anyone give the file contents and the modified version of the same file which would cause a conflict.
Conflicts happen when merging changes that happened on a same base, so to generate a conflict you need to start a branch from a commit that happened before the last commit of
master:If you have the following you can’t get a conflict because modifications happened sequentially:
There’s nothing to merge, it’s either branch or master.
On the contrary, the following will trigger a merge conflict if
branchandmasterhave made modifications on the same portion of a file, because they can be unrelated:The conflict will happen on merging
branchintomaster, git won’t be able to say if you want to take the modification ofbranchor ofmaster, or both.