Git is not making a conflict when I think it should be

I am learning how to deploy a django website and for that I have 2 copies of the code in 2 Git branches one for developing (master) and the other for deploying (deployment) with differint configuarations.

I did some modification in master branch and want them to be availabe in deployment. I should have some conflicts because of the different configurations files like in settings.py there is debug=True in master and allowed hosts are empty, in the other hand it is False in deployment and allowed hosts are added.

Git is not making any conflicts with these 2 lines so I am not able to choose which one I want when merging into deployment.

side note: the modifications in git master branch that I want to bring to deployment should not do any conflicts. the conflicts I am waiting are just in already existed differences in the code (the purpose of having these 2 branches).

The explanation has been provided succinctly in the comments but here is a little more detailed explanation of why there is no conflict.

When merging A and B, git does not just take a look at the 2 tips and see if they are different to create a conflict. That would mean that all merges would produce conflicts which is not what you want as a developer. What git actually does is compare how the two tips changed compared not against each other but against a common ancestor (think of the closest common ancestor in history but in complex branch histories it can be more... interesting).

So, say that A and B have a common ancestor C. Now, git sees how things changed C vs A and C vs B. Now git takes those 2 sets of differences and tries to merge them... when there is a clash, you get a conflict.

So, to your example, if on one branch you have debug=False and in the other branch you have debug=True, the only way for that to produce a conflict is if in the common ancestor you have a line that has a value different from False or True.

Вернуться на верх