Why is there a conflict for only one commit instead of two in my redirect operation?

I have a repository rep1with two commits on a branch master. These commits have the file.txtfollowing contents:

line1
line2

I clone rep1in rep2and check out the remote branch as tracking:

git checkout --track rep1/master

Then in this repository I change the first line file.txtas follows:

line1-modified-rep2
line2

Make a commit. Then change your second line to

line1-modified-rep2
line2-modified-rep2

Make a commit. So, here in rep2, I added two commits to a branch masterthat tracks the remote branch rep1/master.

Now I am going to create a conflict. In the remote repository, rep1I create a third commit (there are already two), changing file.txton the first and second lines:

line1-modified-rep1
line2-modified-rep1

, . rep2 rep1, rebase .

, rebase rep2 ( -rep2) rep1 ( prefix -rep1), :

  • rep2, line1-modified-rep1 vs line1-modified-rep2
  • rep2, line2-modified-rep1 vs line2-modified-rep2

, rep1. ?

PS. , .

EDIT:

, rebase :

A--D (rep1)
 \
  B--C (rep2)

: enter image description here

enter image description here

, :

line1-modified-rep2
line2

git, phpstorm ( rep1):

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
+4
3

TL; DR

. - , , ; .

, ; file.txt, :

mkdir rep1
cd rep1
git init
printf "l1\nl2\n" > file.txt
git add touch.txt
git commit -m "initial commit"

cd ..
git clone rep1 rep2
git remote rename origin rep1 # for clarity
cd rep2
sed -i '.txt' 's/l1/l1rep2/' file.txt
git commit -am "append 'rep2' to first line"
sed -i '.txt' 's/l2/l2rep2/' file.txt
git commit -am "append 'rep2' to second line"

cd ../rep1
sed -i '.txt' 's/$/rep1/' file.txt
git commit -am "append 'rep1' to both lines"

cd ../rep2
git fetch

rep2 ( file.txt ):

enter image description here

, rep2,

git rebase rep1/master

, , , rebase - , , ; , Git .

-, Git "AB patch" commit D. Git ; , Git , :

enter image description here

, , Git , , file.txt

l1-rep2
l2

( , , ). :

git commit -am "conflict resolution"

enter image description here

git rebase --continue Git, "BC " commit E... ! ; file.txt commits B E , - ,

enter image description here

+3

, . "" → " PhpStorm", remote/master. , , , git

Applying: rep2-commit 2
Applying: rep2-commit 3

, , , , rep2-commit 2. rep1, .

+2

. rebase - :

A--B--C--D--E rep2 \ F rep1

A--B--C \ F--D'--E' rep2

Right?

git , , D E . Commit D F, . D '. E D '. Commit E - 2 file.txt D. , : D ' . , content.txt commit D ' file.txt commit D. E' D. .

+1

All Articles