Ignore Git revisions in git blame
Since Git 2.23, Git added support for ignoring revisions in git blame
. This feature is handy when you have a few revisions that only change code style or formatting and you want to exclude them for when you do git blame
.
You can utilize this feature by calling git blame
with --ignore-rev
or --ignore-revs-file
flag, or set blame.ignoreRevsFile
config. There’s a good blog post by Micheal Heap about this feature here:
So, the reason I want to write about this feature despite it’s already available for a while now is that GitHub now officially supports it!
You can now add a .git-blame-ignore-revs
file to the root of your repository, and GitHub will now exclude those revisions from the blame view.
You can see an example usage of this feature on Ruby’s Git repository, where they use this feature to exclude a commit that changes the whitespaces of the whole project.
If you ever thinking about cleaning up the code style of your repositories so they would be consistent, I think now is the right time!