You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create two new commits on Feature2 branch
For example, re-edit test file test17 line 12 twice
git checkout Feature2
# edit test17, line 12
git add test17
git commit -m "Feature2: edit1 the file test17, line 12"
Here is the second edit:
git checkout Feature2
# edit test17, line 12
git add test17
git commit -m "Feature2: edit2 the file test17, line 12"
create two new commits on Feature3 branch
For example, edit test file test17twice
git checkout Feature3
# edit test17, line 12
git add test17
git commit -m "Feature3: edit1 the file test17, line 12"
Here is the second edit:
git checkout Feature3
# edit test17, line 12
git add test17
git commit -m "Feature3: edit2 the file test17, line 12"
Now, preparation work is done, and the project log becomes (diverge appears):
Step1: Rebase Feature3 branch
git checkout Feature3
git rebase Feature2
Merge conflict raised here. Looking into the file /Users/dora/git-merge-conflicts-test-1/.git/rebase-apply/patch, the content is:
Check current working directory and index
# As can be seen, now in process to rebase branch Feature3 on the latest commit of Feature2 branch
git status
```
# now not in any branch, in a detached rebase status
git branch
```
# head is at:
git show --oneline head
In next step, we need to resolve the conflict.
Step2: Resolve rebase conflict
Current project status:
As we can see from last step, the conflict is content conflict in the file test17. Current test17 is:
( checking out Feature3 branch)
Modify test17 to:
Then, mark the rebase conflict resolved and continue rebase:
# resolve conflict
git add test17
# check status
git status
```
# continue rebasing
git rebase --continue
```
The project history becomes (the Feature3 edit1 commit is already applied on tip of Feature2):
However, a new conflict raised - when continue rebasing. As we can see from the log here,
Feature3 edit1 commit is already applied (after resolving the rebase conflict);
Feature3 edit2 commit now raise a rebase conflict --> need to resolve.
In the next step, the developer is going to resolve the second conflict.
Step3: Resolve the second rebase conflict
First, get more details about the second conflict.
# look into the patch file
vim /Users/dora/git-merge-conflicts-test-1/.git/rebase-apply/patch
# project status
git status
```
# check branch
git branch
```
The conflict file is test17, current version is:
( conflict between the newly-applied Feature3 edit1 commit on tip of Feature2, and HEAD of Feature2 branch, which is Feature2 edit1 commit)
Now, resolve the conflict:
# mark conflict2 resolved
git add test17
# check current status
git status
```
# continue rebasing
git rebase --continue
# check status again
git status
```
Now the rebase process is done, and the project history becomes:
The previous two commits of Feature3 branch now is rebased to the head of Feature2 branch. ( SHA changed, the old Feature3 commits are not visible in log anymore)
Here is the comparison scratch:
Step4: Merge Feature2 branch forward
git checkout Feature2
git merge Feature3
Step5: Check git log and git reflog to explore data
Feature3 branch was derived from Feature2, also
git rebase
was done in #17 . Based on this, test case 18 is going to testrolling back
after rebasingScenario abstract
Feature2
andFeature3
),Feature3
was derived fromFeature2
;Feature3
branch was created,Feature3
made several commit ( for example, all edit lineX of fileY)Feature2
edit line X of fileY, 1 commitFeature3
back toFeature2
Feature3
branch --git rebase Feature2
Results:
rebasing
, andgit log
is modified directly.Data could be explored:
git log
git reflog
git log
git reflog
Detailed steps:
Step0: prep
test15
onFeature2
branchFeature2
andFeature3
Feature2
branchFor example, re-edit test file
test17
line 12 twiceHere is the second edit:
Feature3
branchFor example, edit test file
test17
twiceHere is the second edit:
Now, preparation work is done, and the project log becomes (diverge appears):
Step1: Rebase
Feature3
branchMerge conflict raised here. Looking into the file
/Users/dora/git-merge-conflicts-test-1/.git/rebase-apply/patch
, the content is:Check current working directory and index
``` # now not in any branch, in a detached rebase status git branch ```
In next step, we need to resolve the conflict.
Step2: Resolve rebase conflict
Current project status:
As we can see from last step, the conflict is
content conflict
in the filetest17
. Currenttest17
is:( checking out
Feature3
branch)Modify
test17
to:Then, mark the rebase conflict resolved and continue rebase:
``` # continue rebasing git rebase --continue ```
The project history becomes (the Feature3 edit1 commit is already applied on tip of Feature2):
However, a new conflict raised - when continue rebasing. As we can see from the log here,
In the next step, the developer is going to resolve the second conflict.
Step3: Resolve the second rebase conflict
First, get more details about the second conflict.
``` # check branch git branch ```
The conflict file is
test17
, current version is:( conflict between the newly-applied Feature3 edit1 commit on tip of Feature2, and
HEAD
of Feature2 branch, which is Feature2 edit1 commit)Now, resolve the conflict:
``` # continue rebasing git rebase --continue # check status again git status ```
Now the rebase process is done, and the project history becomes:
The previous two commits of Feature3 branch now is rebased to the head of Feature2 branch. ( SHA changed, the old Feature3 commits are not visible in log anymore)
Here is the comparison scratch:
Step4: Merge Feature2 branch forward
Step5: Check
git log
andgit reflog
to explore dataFeature2
branch:Feature3
branch:As we can see,
rebase
is applied one by one on the tip of the base branchrebasing
git log
git reflog
rebase conflict
git log
git reflog
about conflictsgit log
git reflog
The text was updated successfully, but these errors were encountered: