1

I was working in a branch and my commit had a very detailed message. The format was:

Title

Details (multiple lines). 

I created an MR but when the MR was merged I can see the merge commit and my new commit with only the Title. The details are gone. If I do git show $sha on either the $sha of my local branch or do git log on the remote branch I can see the full message.
But in master I can only see the title.
How can this be happening? Is there some Gitlab configuration that could be causing this?

Update after @Ôrel comment:
The squash commits was preselected.
The branch had 2 commits with the same format i.e. Title/Detailed message.
The merged (squashed) commit has the title of one commits (not the one that was top of the branch) and the details removed. How is the commit message selected in this kind of squash/merge?

7
  • Are you squashing the branch on merge ? you can see this on merge request creation "Squash commits when merge request is accepted"
    – Ôrel
    Commented Sep 30, 2022 at 7:06
  • @Ôrel: Yes I saw that preselected
    – Jim
    Commented Sep 30, 2022 at 7:10
  • @Ôrel: Is that the reason? There were 2 commits in the branch actually. I am sorry I didn't mention it
    – Jim
    Commented Sep 30, 2022 at 8:05
  • @Ôrel: Now I notice that it used as title one of the 2 commits title. The order was A<-B<-Branch i.e. A was on top. And on squash it used the title of commit B and removed the details from A and B. How is that squash supposed to work?
    – Jim
    Commented Sep 30, 2022 at 8:08
  • Squash will use your MR content not your commit content
    – Ôrel
    Commented Sep 30, 2022 at 8:10

1 Answer 1

2

By default gitlab will use the title of the merge request on squash commit

%{title}

you can add more info cf https://docs.gitlab.com/ee/user/project/merge_requests/commit_templates.html#default-template-for-squash-commits

If you want to keep info from commits you can use a template like:

%{title}

%{all_commits}

To find the template

  1. On the top bar, select Main menu > Projects and find your project.
  2. On the left sidebar, select Settings > Merge requests.

enter image description here

2
  • Where should that template be?
    – Jim
    Commented Sep 30, 2022 at 10:13
  • On the top bar, select Main menu > Projects and find your project. On the left sidebar, select Settings > Merge requests.
    – Ôrel
    Commented Sep 30, 2022 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.