git push code conflict resolution

Conflict situation one

First, A and B pull the v1 version of the code from the remote warehouse at the same time, and then B first modifies the code to produce the v3 version of the code and submits it successfully, then A modifies the v1 version of the code to produce the v2 version of the code, and wants to submit it to origin/master, but the latest version of the remote is not the previous v1, and there is a conflict here (identified by the red line).

insert image description here

Examples are as follows

Win here to modify the sorting algorithm to sort from large to small

insert image description here

Then do add and commitoperation, but nopush

insert image description here

Then the ubuntu side made the following changes

insert image description here

Then do add , commitand push operate on ubuntu

insert image description here

pushAt this time , there will be conflicts when doing operations on win

insert image description here

At this point, the input git pull will automatically help us merge into the local branch, and then we can masterproceedpush

insert image description here

It can be seen that this is an mergeaction

insert image description here

Conflict situation two

First modify the README file on the win side

insert image description here

At the same time win here addand commitoperation, but notpush

insert image description here

Then ubuntu modifies the same location in the README file

insert image description here

Then win here to pushoperate again, there is a conflict

insert image description here

then proceedpull

insert image description here

But at this time, because the modified location of win and the pulled version are modified at the same location, a conflict occurs , which cannot be automatically mergeresolved, and must be resolved manually. At this time, the conflicting README file is as follows

insert image description here

Then win here and do addthe operation of commitand to resolve the conflictpush

insert image description here

Guess you like

Origin blog.csdn.net/qq_42120843/article/details/130968856