WB
Home About Notes

Editing Old Commit Messages

  20th August 2024
  1 minute
  git

So you have some commit messages you want to update? You need git-filter-repo!

git filter-repo is a versatile tool for rewriting history, which includes capabilities I have not found anywhere else. It roughly falls into the same space of tool as git filter-branch but without the capitulation-inducing poor performance, with far more capabilities, and with a design that scales usability-wise beyond trivial rewriting cases. git filter-repo is now recommended by the git project instead of git filter-branch.

The only thing is, all the merge conflicts will stop it working. Do you even rerere? No? well lets start.

First off, you will need to enable it.

git config --global rerere.enabled 1

But wait, merge conflicts from the past will be unknown. You need to train it! Download (rerere-train)[https://github.com/gitster/git/blob/master/contrib/rerere-train.sh]

Now you can train rerere to know all the merge conflict resolutions.

sh ./rerere-train.sh production

Now, install git-filter-repo

brew install git-filter-repo

Check the commit message

 git cat-file -p 22a49a206052387bc35fd1ff6490abac831f0b81

Now you can edit the message.

git filter-repo --force --commit-callback '
if commit.original_id == b"9022c5c11264015e74f7ef4651ca56da185cf78c":
    commit.message = b"change column header \n"
'

Boom! all done.

Lets make something together!

Get in touch at [email protected]


Copyright 2025 © All rights Reserved.
Crafted Web Development. Built With