I've been reading about git merge -s ours strategy for a few hours. All resources I've found state that it tricks Git into ignoring commits that happened before the "fake" merge that is made using -s ours strategy and I can't understand why:
Suppose I have the following git history, with master and feature branches that have lots of diff between them:
(A)------(B)-------(C)------(D) <---[master] <---[HEAD]
\
\
(E)------(F)------(G) <---[feature]
Now I run git merge -s ours feature, and the result is commit H:
(A)------(B)-------(C)------(D)--(H) <---[master] <---[HEAD]
\ /
\ /
(E)------(F)--------------(G) <-- [feature]
Then I make more commits on both branches:
(A)------(B)-------(C)------(D)--(H)------(K)------(L) <---[master] <---[HEAD]
\ /
\ /
(E)------(F)--------------(G)------(I)------------(J) <-- [feature]
And then, while on master I run git merge feature
Correct me if I'm wrong, at that point Git will:
- Compute commit
Gas themerge-base - Run diff between
GandL - Run diff between
GandJ - Make a copy of commit
G, sayG'and apply the above 2 diffs to commitG' - Make
LandJthe parents ofG'
Here's what I don't understand: According to the docs the changes from commits E and F won't affect the merge, but the diff between G and L will still reflect the changes made in commits E and F because G was "born" from them, so how is it possible that the changes in these commits will not affect the merge simply because ours strategy was used ?
In a more extreme case, if these branches diverged more wildly and there are, say, 100 files in feature branch (that were introduced before G) and that are not in master, then won't they still appear in the diff between G and L during the last merge ? **Edit: I can't see why they won't appear in the diff