I have rep1
repository with two commits on master
branch. These commits have file.txt
with the following content:
line1
line2
I clone rep1
into rep2
and checkout remote branch as tracking:
git checkout --track rep1/master
Then in this repository I modify first line of file.txt
to be:
line1-modified-rep2
line2
Make commit. Then modify its second line to be
line1-modified-rep2
line2-modified-rep2
Make commit. So, here in the rep2
I have added two commits to master
branch that tracks remote rep1/master
branch.
Now I'm going to generate a conflict. On the remote rep1
repository I create third commit (there are already two there) modifying file.txt
on the first and second lines to be:
line1-modified-rep1
line2-modified-rep1
Ok, now we're all set for merge conflict. I push commits from rep2
to rep1
, get rejected and when prompt for rebase
select this option.
Now, I was reading that rebase
would apply my two commits from rep2
(where I modified two lines with prefix -rep2
) on top of the synced down third commit from rep1
(with modified lines with prefix -rep1
) and so I'm expecting two merge conflicts:
- when first commit from
rep2
would be applied and the linesline1-modified-rep1 vs line1-modified-rep2
will get conflicted - when first commit from
rep2
would be applied and the linesline2-modified-rep1 vs line2-modified-rep2
will get conflicted
But there is only one merge conflict and upon its resolution I can successfully push my commits to the rep1
. What am I missing here?
PS. Sorry for the lengthy elaboration, I tried to lay out my case as clear as possible.
EDIT:
So the setup before rebase is the following:
A--D (rep1)
\
B--C (rep2)
Added screenshots of the resolution process:
So the resulting file after the conflict resolution contains these lines:
line1-modified-rep2
line2
This is a log of git commands recorded by phpstorm (origin is rep1
here):
23:19:49.586: git -c core.quotepath=false fetch origin --progress --prune
remote: Counting objects: 5, done.[K
remote: Total 3 (delta 0), reused 0 (delta 0)[K
From E:/rep1
acc72ac..e6317e8 master -> origin/master
23:20:39.118: cd E:\rep2
23:20:39.118: git -c core.quotepath=false rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: rep2-commit 2
Using index info to reconstruct a base tree...
M file.txt
Falling back to patching base and 3-way merge...
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
Failed to merge in the changes.
Patch failed at 0001 rep2-commit 2
The copy of the patch that failed is found in:
e:/rep2/.git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
23:24:33.418: cd E:\rep2
23:24:33.418: git -c core.quotepath=false add --ignore-errors -- file.txt
23:24:33.630: cd E:\rep2
23:24:33.630: git -c core.quotepath=false rebase --continue
Applying: rep2-commit 2
Applying: rep2-commit 3