dorawyy/git-merge-conflicts-test

[testcase notes] #14: rebase branch Feature2 on Feature3 (only commit on Feature2, base branch)

Opened this issue · 0 comments

Feature3 branch derived from Feature2, rebase Feature3 before merging

Scenario abstract

  • developer1 worked on two branches (Feature2 and Feature3), Feature3 was derived from Feature2;
  • after Feature3 branch was created, there was only commits on Feature2 branch
  • now developer1 would like to merge Feature3 back to Feature2
  • however the developer would like to rebase Feature3 branch -- git rebase Feature2
  • What would happen?

wechatimg257

Results:

  • no conflict, fast-forward rebase , no merge happened (as already up-to-date)

Data could be explored:

  • record of rebase in git reflog only. ( no record in git log, no visible commit)

Detailed steps:

Step0: prep

  • create and edit test file test14 on Feature2 branch
git checkout Feature2
touch test14

# edit test14

git add test14
git commit -m "testcase14: startpoint (create file test14)"

screen shot 2017-10-16 at 12 22 30 am

screen shot 2017-10-16 at 12 21 47 am

  • sync Feature2 and Feature3
git checkout Feature3
git merge Feature2

screen shot 2017-10-16 at 12 23 05 am

  • create a new commit on Feature2 branch only
    For example, re-edit test file test14
git checkout Feature2

# edit test14

git add test14
git commit -m "Feature2: edit the file test14"

screen shot 2017-10-16 at 12 24 18 am

screen shot 2017-10-16 at 12 24 53 am

Now, preparation work is done, and the project log becomes:
screen shot 2017-10-16 at 12 25 10 am

Step1: Rebase Feature3 branch

git checkout Feature3
git rebase Feature2

screen shot 2017-10-16 at 12 26 56 am

screen shot 2017-10-16 at 12 27 16 am

Feature3 branch moves 1 commit forward to be sync with Feature2 branch. The rebase went smooth, no conflict. Also, as Feature3 has no commit, the head of Feature3 and Feature2 point to the same commit already.

Step2: Merge Feature3 back to Feature2

git checkout Feature2
git merge Feature3

screen shot 2017-10-16 at 12 29 25 am

no commit to merge, no change.

Step3: check git log and git reflog

  • Feature2 branch:
git checkout Feature2
git branch
git log
git reflog

screen shot 2017-10-16 at 12 31 41 am

screen shot 2017-10-16 at 12 30 42 am

  • Feature3 branch:
git checkout Feature3
git branch
git log
git reflog

screen shot 2017-10-16 at 12 32 54 am

screen shot 2017-10-16 at 12 33 23 am

As we can see,

  • the rebase process is done with no extra commit
    • no record in git log
    • only visible in git reflog
  • as no extra commit on Feature3, no merge is done