Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to squash commit when approve merge request, gitlab

Tags:

git

gitlab

I have two branches master and release at gitlab.

At release branch, I hope it will only have commit message like: v0.1.0, v0.1.1.

Say after I finished developed v0.1.0, I have have several feature and bugfix commits in master say

c1. bugfix1
c2. feature1 
c3. feature2

I will create merge request in gitlab from master to release, but I hope to make these three commits into one v0.1.0, and squash c1 c2 c3.

Now , in my existing settings, I will have 4 commit messages:

Merge breanch 'master' into release
c1
c2
c3

Is there a way to squash it when I approve at gitlab so that there message will squash into:

 v0.1.0

Please note that these two branch are all proteced branches, and if possible I hope there will be NO git command on release and master branch , and only gitlab operations

like image 462
JaskeyLam Avatar asked Nov 02 '25 02:11

JaskeyLam


1 Answers

git checkout release
git merge --squash master
git commit -m "Suitable Message of your choice"

This will take all the commits from the master branch, squash them into 1 commit and then merge it with your release branch.

like image 161
Shravan40 Avatar answered Nov 04 '25 10:11

Shravan40



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!