For example, there are two branches, master
and develop
. For 1.txt
files,
master分支
:
222
3333 66
555
develop分支
:
222
4444 77
888
First there is master, then I created the develop branch, then modified 1.txt under the develop branch, then add and commit, then switched back to the master branch, and then merged, only 66 and 77 conflicts were reported, and others No conflict reported between the two places
Why would there be a conflict if there are only 66 and 77? And 4444 and 3333, and 555 and 888 do not conflict? Don’t understand
Look at the picture above, the master branch is 555555, I changed it to dev in 5445, then add commit, then switch back to the master branch, merge, there is no conflict, and finally merge to 5445. Is this what you said?
巴扎黑2017-05-02 09:49:39
Whether Conflicts occur depends on the order of commit modifications
My friend upstairs mentioned automatic merging, which means there will be no conflicts. For example:
Master above, you have a commit with the content "1234"
At this time, you create a new branch based on master, called develop
,那么这个 develop
branch. There is also a commit with the content "1234" on it
Then you submit a new commit and change "1234" to "1234 666". Then if you merge
at this time, there will be no conflict
Another example of a conflict situation:
master
There is a commit in it, the content is "1234"master
里面有一个 commit,内容是 "1234"
你在这个 commit 之后创建了新的 branch,叫 develop
。那这个时候你的 develop
after this commit, called develop
. Then at this time, your develop
branch has the first commit with the content "1234"develop
里面,提交了一个 commit,内容是 "1234 777"
在这期间,你的 master
更新了,你的同事或者朋友,或者你自己,在 master
Then you submitted a commit in develop
, the content is "1234 777"
During this period, your master
was updated, and your colleagues or friends, Or you yourself, submit a new commit on master
and update it to "1234 666"
If you merge again at this time, there will be a conflict, because git finds that the two branches have a common ancestor (ancestor), which is "1234", but git doesn't know whether you are merging now or want to "666" " Still "777"
Back to your question, I suggest you first look at the commit history of your two branches and compare them. See if you can find a situation like this, that is, two branches have a common commit as the starting point (ancestor), but subsequent commits diverge (pert)🎜 🎜If you still can’t explain your problem, please send me your github address if it’s convenient🎜
给我你的怀抱2017-05-02 09:49:39
Because there is also automatic merging. Did you see the conflict when merging branches manually?
PHP中文网2017-05-02 09:49:39
I tried it and found that it doesn’t work. Here is the original answer.
It’s all my guessing.
At first the master looks like this:
222
3333 22
555
Then you fork a develop and modify it like this:
222
4444 77
888
At this time, develop can be directly merged with master without conflict, because develop is a modification to master after master.
But you didn’t merge develop, but changed master:
222
3333 66
555
At this time, there is a conflict between 66 and 77. Because git knows that 4444 in develop was changed from 3333, and 888 was changed from 555, the current master position still has 3333 and 555. But 77 was originally changed from 22, but now the master's 22 has become 66. There are two conflicting modifications, and git cannot merge 77 to 66.
In other words, master and develop were originally on the same line, but if you change the master, the new master is not on the same line as the original develop.