TIL that pathnames in git configs can be optional

git-blame shows what revision and author last modified each line of a file.

There are cases where you may want to ignore certain revisions, e.g. when a revision only contains changes that resulted from a code formatter changing the indentation of the entire codebase.

To ignore such commits, you can use:

git blame --ignore-rev <rev>

Or, you can ignore multiple revisions from a file:

git blame --ignore-revs-file <file>

By convention, the ignore-revs-file is called .git-blame-ignore-revs and placed at the repository root. Git forges like GitHub and GitLab support this file directly in their blame views.

If you want to default to .git-blame-ignore-revs for the ignore-revs-file locally, you can set the config option blame.ignorerevsfile... and figure out that it's a bad idea. git-blame fails if the ignore-revs-file doesn't exist - and in most repositories it doesn't exist. So don't set blame.ignorerevsfile.

... or so I thought until I read a comment by ilostmymangoman on hacker news. As of git 2.52 (Nov 2025), you can mark config file paths as optional using the :(optional) prefix.

That means you can safely configure an ignore-revs-file in your ~/.gitconfig without breaking git-blame if the file doesn't exist:

[blame]
    ignoreRevsFile = :(optional).git-blame-ignore-revs
TIL (1)
git (2)

Browse Topics Browse All Posts

Feel free to write me if you have any questions or feedback