I use git merge --no-edit ...
in a script.
When doing git merge --no-edit ...
, git generates an automatic commit message like:
- "Merge branch X into Y" or
- "Merge commit X into Y" or
- "Merge remote-tracking branch 'X' into Y".
It's possible to customize that message by doing git merge --no-edit -m "Custom message"
, but that overrides the automated one.
I'd like to have both: A custom message, but also keep the automated one appended to it.
Is there such a possibility? For example, via a placeholder like git merge -m "Custom message $AUTOMATIC_MESSAGE"
? (is there such a magic placeholder?)
Edit 1:
One way to achieve what I want would be
- Use
git merge
to create a merge with automated message - Then
git commit --amend
to edit the message in editor and preprend "Custom message"
However, I want the merge to be automated without a stop in editor.
Edit 2:
I realized I could proceed as follows in a script: do a merge with an default automatic message, then read that automated merge message post-factum via git log -1 --pretty=%s
, then amend the message:
git merge ...
git commit --amend -m "Custom message: $(git log -1 --pretty=%s)"
However, is there a more efficient way by using just git merge
without amending the commit?