Ignore commits in git blame

Posted on 2023-12-02 in Trucs et astuces

Commits that change formatting are a pain in git because they make using git blame much harder. It turns out, you can ask git to ignore these commits when running git blame with the --ignore-rev option and passing it a commit hash. You can even do things better and create a .git-blame-ignore-revs listing the full commit hashes you want to ignore and pass it to git with --ignore-revs-file.

To make things even more simple, you can configure git to use this file automatically with:

git config blame.ignoreRevsFile .git-blame-ignore-revs

It even works natively on GitHub!

Initially seen on the Black documentation.

git