On the problem of Git, the problem of file overwriting each other

< H2 > question 1: < / H2 >

user An and B, file a, the same branch
user A first pull (time is 12:00), then edit file a, then commit and push,push time is 13:00
user B first pull (time is 12:00), then edit file a, then commit and push,push time is 13:01

in the end, does the file an in repo belong entirely to user B, or do the changes made by both users exist?

< H2 > question 2 < / H2 >

user An and B, file b, the same branch
user B submitted a commit and push for modifying file b (time is 14:00)
user A started pull (time is 14:01), but found that there was an error, indicating that there was a local commit without Synchronize, so the modification commit of file b at hand was dropped, and then pull, succeeded, and then merge, finally push out

.

does the file b in repo contain the modification results of users An and B at this time?

Mar.23,2021

question 1:

user B will have a push error because repo's submission is already ahead of B's local repository. Solutions such as your problem 2 pull, B need to merge first and then push

question 2:

repo is the last result of B merger

< hr >

in fact, this kind of problem can be understood more clearly by doing it yourself


question 1 all have
question 2, do not understand

Bbcommitpull14:00

this is pull? Why do I think it's push
OK, if this is pull, then the commit of B does not have push, then the remote end of A pull commit merge push, is only A

.

these premises are that the code changed by an and b does not conflict. If there is a conflict, change the same code block, take question 1 as an example. B will first prompt you to pull down a new push at 14.01pm push (this is normal, regardless of whether there is a conflict or not. I guess you may forget to write that), B will report a conflict after the pull comes down, and you need to fix the conflict (such as modifying the conflicting code block) so that you can successfully push

.
Menu