Read more

Ignore commits when git blaming

Niklas Hä.
January 03, 2024Software engineer at makandra GmbH

You can ignore certain commits when using git blame with the --ignore-revs-file option. This is handy to ignore large rubocop commits or big renamings in your project. You can add and commit a .git-blame-ignore-revs file in your project to track a list of commits that should be ignored.

# a list of commit shas
123...
456...
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Use git blame with the --ignore-revs-file option and ignore the SHAs specified in .git-blame-ignore-revs.

git blame --ignore-revs-file .git-blame-ignore-revs

If you want to use this flag by default, you can consider adding it to your git config Show archive.org snapshot for the current project:

git config blame.ignoreRevsFile .git-blame-ignore-revs
git config blame.markIgnoredLines # mark lines that were attributed to another commit with a ?
git config blame.markUnblamableLines # mark lines that could not be attributed to another revision with a *

Most editors support this flag as well.

Note

With great power comes great responsibility. Make sure you really want to ignore a certain commit before adding to the ignore revs file.

Posted by Niklas Hä. to makandra dev (2024-01-03 11:00)