dorawyy / git-merge-conflicts-test

This repo is for testing of git functionalities / different merging conflict scenarios, and CI tools usage
2 stars 4 forks source link

[testcase notes] #15: rebase branch Feature2 on Feature3 (both commits, diff files) #17

Open dorawyy opened 7 years ago

dorawyy commented 7 years ago

Feature3 branch derived from Feature2, rebase Feature3 before merging

Scenario abstract

wechatimg258

rebase_conflict

Results:

Data could be explored:

Detailed steps:

Step0: prep

git checkout Feature2
touch test15

# edit test15

git add test15
git commit -m "testcase15: startpoint (create file test15)"
screen shot 2017-10-16 at 12 46 49 am screen shot 2017-10-16 at 12 46 05 am

edit test15

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

<img width="722" alt="screen shot 2017-10-16 at 12 49 12 am" src="https://user-images.githubusercontent.com/16771854/31600577-daa587e2-b20b-11e7-8ba1-df652aaf4cb1.png">

<img width="753" alt="screen shot 2017-10-16 at 12 48 31 am" src="https://user-images.githubusercontent.com/16771854/31600543-c113f408-b20b-11e7-9ef3-d67138412244.png">

* create a new commit on `Feature3` branch
For example, create and edit test file `test15-1`

git checkout Feature3 touch test15-1

edit test15-1

git add test15-1 git commit -m "Feature3: created, edited the file test15-1"

<img width="820" alt="screen shot 2017-10-16 at 12 50 54 am" src="https://user-images.githubusercontent.com/16771854/31600646-16bb685a-b20c-11e7-8d41-8d7039dd823d.png">

<img width="756" alt="screen shot 2017-10-16 at 12 50 23 am" src="https://user-images.githubusercontent.com/16771854/31600625-05f8b3a6-b20c-11e7-9550-8f6e5fd6decf.png">

Now, preparation work is done, and the project log becomes (diverge appears):
<img width="666" alt="screen shot 2017-10-16 at 12 51 39 am" src="https://user-images.githubusercontent.com/16771854/31600686-358ae134-b20c-11e7-9e3a-dcb5f779bae7.png">

### Step1: Rebase `Feature3` branch

git checkout Feature3 git rebase Feature2

<img width="554" alt="screen shot 2017-10-16 at 12 52 56 am" src="https://user-images.githubusercontent.com/16771854/31600733-62557cf6-b20c-11e7-8e67-2c00e6187991.png">
<img width="753" alt="screen shot 2017-10-16 at 12 53 36 am" src="https://user-images.githubusercontent.com/16771854/31600770-7a1c8122-b20c-11e7-8440-48fc6d090ded.png">
<img width="1000" alt="screen shot 2017-10-16 at 12 54 11 am" src="https://user-images.githubusercontent.com/16771854/31600790-8c30bd92-b20c-11e7-8f4f-c0b3648877f3.png">

`Feature3` branch is moved, `rebase` is done successfully. However, no commit about `rebase` is created.

### Step2: Merge `Feature3` back to `Feature2`

git checkout Feature2 git merge Feature3

<img width="628" alt="screen shot 2017-10-16 at 12 55 48 am" src="https://user-images.githubusercontent.com/16771854/31600849-c7f92bca-b20c-11e7-8a02-9a832bb454d5.png">
<img width="1002" alt="screen shot 2017-10-16 at 12 57 04 am" src="https://user-images.githubusercontent.com/16771854/31600902-f53528f0-b20c-11e7-8d2b-132af8766a60.png">

A fast-forward merge is done, no merge commit is created.

### Step3: check `git log` and `git reflog`

* `Feature2` branch:

git checkout Feature2 git branch git log git reflog

<img width="621" alt="screen shot 2017-10-16 at 12 57 43 am" src="https://user-images.githubusercontent.com/16771854/31600936-0c2205ce-b20d-11e7-9052-397810d04353.png">
<img width="550" alt="screen shot 2017-10-16 at 12 58 46 am" src="https://user-images.githubusercontent.com/16771854/31600995-3339f8ec-b20d-11e7-9585-49ada4e39442.png">

* `Feature3` branch:

git checkout Feature3 git branch git log git reflog


<img width="550" alt="screen shot 2017-10-16 at 12 58 46 am" src="https://user-images.githubusercontent.com/16771854/31601037-638e2ffe-b20d-11e7-871a-8d7104cb6be5.png">
<img width="550" alt="screen shot 2017-10-16 at 12 58 46 am" src="https://user-images.githubusercontent.com/16771854/31601084-7bb76ec4-b20d-11e7-839c-4a80e54fba2e.png">

**As we can see,** 
* the `rebase` process is done with no extra visual commit
    * no record in `git log` 
    * only visible in `git reflog`
* fast-forward merging, thus no merge commit is created
    * no record in `git log`
    * only visible in `git reflog`