Have you ever run git blame, looked at the commit for a line, and seen some big refactoring or formatting commit? It’s so frustrating not to be able to find the useful context on changes when this happens. When adding StandardRB or RuboCop, or when making changes to your .rubocop.yml configuration, you’ll probably end up with a large commit like this that doesn’t include valuable context when spelunking history.

Enter .git-blame-ignore-revs. The format of the file is just a list of commit SHAs. The file will automatically cause GitHub to ignore the corresponding commit when in their blame view. You can also configure Git to ignore these commits by setting blame.ignoreRevsFile.

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

One catch is that because git config is not part of the repository, each person using the repo will need to set this config on their own. Also note that git blame will error if the file isn’t present, so this is not a good candidate for global configuration.

Now, git blame and GitHub will ignore these big formatting commits. Never worry about mass reformatting again!

Caleb Hearth

Hash An icon of a hash sign Code Name
Agent 00136
Location An icon of a map marker Location
Denver, CO