Reputation: 536
Trying to figure out how the file1.cpp will look after merging merge request in Gitlab . I(dev1) am working on the dev branch and changed line 2 of file1.cpp, committed and raised merge request . Now, I waited 1 day before merging . By the time another developer(dev2) changed the line 4 of file1.cpp, committed and merged in master . Now, the line 4 is different in my file1.cpp, if compared to file1.cpp from master .So if I merge now my request then how the final version of file1.cpp will look like ?
1) file1.cpp:
line 2 by dev1
...
line 4 by dev2
2) file1.cpp:
line 2 by dev1
...
line 4 by dev1
My doubt is whether line 4 from my will change will be present in final file or line 4 from dev2 will be finally present . If line 4 from dev2 will be finally present , then why it is so ? Because my changes are coming after dev2's changes .
Upvotes: 1
Views: 768
Reputation: 51840
git
will not silently discard your colleague's changes, nor your own changes.
It will either :
If a merge conlict occurs, a generic manual action is :
Note that "the changes are automatically merged by git
" is not a guarantee that your code will work.
Two examples :
Suppose your change is : renaming function computeThis
to computeThat
,
and dev2's change is : call function computeThis
,
your combined changes would lead to something that doesn't compile.
Suppose your change is : add a x -= 1
instruction,
and dev2's change is : add a double d = 1 / x
,
and for some reason, before your change the code explicitly stated that x > 0
in that function,
the result would compile, but there could be a new bug case when x == 1
.
Just to highlight :
the end result should still be tested and reviewed.
Upvotes: 2