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...
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 10:00)