0

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?

torek
  • 448,244
  • 59
  • 642
  • 775
Jim
  • 3,845
  • 3
  • 22
  • 47
  • Are you squashing the branch on merge ? you can see this on merge request creation "Squash commits when merge request is accepted" – Ôrel Sep 30 '22 at 07:06
  • @Ôrel: Yes I saw that preselected – Jim Sep 30 '22 at 07:10
  • @Ôrel: Is that the reason? There were 2 commits in the branch actually. I am sorry I didn't mention it – Jim Sep 30 '22 at 08: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 Sep 30 '22 at 08:08
  • Squash will use your MR content not your commit content – Ôrel Sep 30 '22 at 08:10
  • @Ôrel: What do you mean by MR content? There was text in the MR but that also was not used. – Jim Sep 30 '22 at 08:11
  • Note that a squash operation is *not* a merge (calling it a "squash merge", as Git does, was probably a mistake). You can still feel free to use it and configure it however you like, just keep in mind that it's not a *merge*. Note also that almost everything having to do with a "merge request" is specific to GitLab (MRs are not part of base Git). – torek Sep 30 '22 at 13:57

1 Answers1

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

Ôrel
  • 7,044
  • 3
  • 27
  • 46