Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Edit Squash and Merge message on master branch

I just squash and merged my PR with all the commit details which isn’t supposed to be done that way. I’d like to edit the commit message (details) on master so it doesn’t contain all that useless information. Also it is very annoying when hovering over a git blame in Intellij.

As is:

Commit name: Test
  * commit 1
  * commit 2
  * commit 3
  * ...

To be:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Commit name: Test

How do I do that either in terminal or in github web-client?

Thanks a lot!

>Solution :

You can use:

  1. git checkout master to switch over to the master
  2. git commit --amend -m "Commit name: Test" to edit the commit message of the latest commit (your merge commit)
  3. git push --force-with-lease to forcefully push your rewritten history to the main branch.

I would recommend not doing any of that, because you will overwrite the current state of the master branch on your (presumably shared) repository.
Any person who would have already pulled master since you’ve merged your MR would then have a copy of some commits that you want to alter, and they’ll have to deal with your manipulated history as well.

I would suggest you let it go if there’s any chance that:

  • anybody has already pulled from your MR
    or
  • it’s okay to keep the merge-squash message as it is.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading