I’m trying to understand how GitLab makes merge commit. Pure git has different behaviour and it’s not so clear why merge commits are required in GitLab
Let’s say we have empty repository and perform first commit named direct commit to branch
. Then we create a branch b-4
with two commits. Let’s merge b-4
branch into main
.
Note: keep in mind we use Merge commit
method with squash option. Read more at Merge methods.
After merge is done we see the following history in GitLab web-interface (not a screenshot, sorry):
Merge branch 'b-4' into 'main' d08bf37f
Squashed commit ebc509c2
direct commit to branch 34b29e2b
I expect to see something like that in git tree when I run git log --graph --decorate
command:
* commit d08bf37ff7157d48354c001ac066a6a44aece33e (HEAD -> main, origin/main)
| Author: author_name <[email protected]>
| Date: Fri Jun 14 16:30:27 2024 +0300
|
| Merge branch 'b-4' into 'main'
|
| Squashed commit
|
| See merge request author_name/repo_name!1
|
* commit ebc509c25c945b63fbc3f387bb308a54b1006e90
| Author: author_name <[email protected]>
| Date: Fri Jun 14 16:30:27 2024 +0300
|
| Squashed commit
|
* commit 34b29e2b89d38439299feef0ac64b926ba9d5d38
Author: author_name <[email protected]>
Date: Fri Jun 14 16:29:09 2024 +0300
direct commit to branch
But actually I observe the following:
* commit d08bf37ff7157d48354c001ac066a6a44aece33e (HEAD -> main, origin/main)
| Merge: 34b29e2 ebc509c
| | Author: author_name <[email protected]>
| | Date: Fri Jun 14 16:30:27 2024 +0300
| |
| | Merge branch 'b-4' into 'main'
| |
| | Squashed commit
| |
| | See merge request author_name/repo_name!1
| |
| * commit ebc509c25c945b63fbc3f387bb308a54b1006e90
|/ Author: author_name <[email protected]>
| Date: Fri Jun 14 16:30:27 2024 +0300
|
| Squashed commit
|
* commit 34b29e2b89d38439299feef0ac64b926ba9d5d38
Author: author_name <[email protected]>
Date: Fri Jun 14 16:29:09 2024 +0300
direct commit to branch
- Why the tree is not linear?
- Why top level merge commit has
Merge: 34b29e2 ebc509c
line? - What actually happens at low level?
- How to reproduce that behaviour using pure git?
Article How does GitLab merge request with squash work under the hood? doesn’t answer my question.
Thank you for your answers!
1