🔀 git blame Says the Formatter Wrote This Line, Not the Person Who Actually Did
`git blame` is supposed to answer “who last changed this line, and why” – but a large automated reformatting commit (an auto-formatter run project-wide, a mass whitespace or line-ending fix) touches every line it reformats, and from that point on, blame attributes all of those lines to the reformat commit, burying the actual meaningful change and its explanation underneath a commit that says nothing more than “ran prettier on the whole repo.”
🔎 The Problem
$ git blame PaymentService.cs -L 45,45 a1b2c3d4 (Dev Team 2026-01-15 10:00:00) public decimal CalculateTotal(Order o) # Commit a1b2c3d4 is "Run dotnet format across entire solution" - a # mechanical, repo-wide reformat that happened to touch this line'"'"'s # indentation. The commit that actually WROTE this method'"'"'s logic, with # a meaningful message explaining why it works the way it does, is now # buried further back in history - and a normal blame lookup has no way # to know that without manually walking further back commit by commit.
✅ Fix: Tell Git to Look Past Specific Commits
- `git blame –ignore-rev <reformat-commit-sha> file.cs` skips a specific commit and attributes those lines to whatever changed them before it – the single most direct fix once the reformat commit’s hash is known.
- For a permanent, repo-wide fix, creating a `.git-blame-ignore-revs` file listing every large mechanical commit (reformats, mass renames, license header additions) and configuring `git config blame.ignoreRevsFile .git-blame-ignore-revs` makes every future `git blame` in the repository skip these automatically, for every developer, without needing to remember specific commit hashes each time.
- GitHub, GitLab, and most Git-aware editors (VS Code’s GitLens, for instance) respect a `.git-blame-ignore-revs` file automatically once it exists in the repo – so this fix pays off in the blame view everywhere the team actually looks, not just from the command line.
⚠️ Why It’s Worth Setting This Up the Same Day You Do a Big Reformat
- The fix is trivial to apply retroactively but easy to forget entirely – adding the reformat commit’s hash to `.git-blame-ignore-revs` in the SAME commit or the very next one keeps this from becoming a recurring annoyance every time someone reaches for blame on an old file.
- This is worth planning for BEFORE running any large mechanical change across a codebase – deciding in advance that the reformat commit’s hash will be recorded for blame-ignoring turns a known annoyance into a two-minute setup step instead of a recurring “why does blame say the formatter wrote this” question.
A mechanical commit touching every line in a file isn’t lying to blame – it genuinely was the last thing to touch that line – it’s just not the answer anyone actually wanted.




