Dimitri Dewaele
Dimitri Dewaele

Reputation: 10659

Merge branch in GIT and keep the commit message

I want to merge a branch in GIT and keep the COMMIT MESSAGE.

enter image description here

Not wanted: git merge --no-edit This keeps the default message: Merge branch 'master' into develop

Wanted: I want to copy the message: ACC-9187 Reformat code instead of the Merge branch ..... ==> The merge must contain the same message. Offcourse I don't want to type the whole message again...: not: git merge -m "ACC-9187 Reformat code"

==> Any suggestions? Thanks!

Upvotes: 1

Views: 242

Answers (1)

ElpieKay
ElpieKay

Reputation: 30868

After the merge is done and before you make any new commit, run:

git commit --amend -C HEAD^2

If you want a single-line solution:

git merge master -m "$(git log -1 --pretty=%B master)"

Upvotes: 1

Related Questions