Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Git

Git: Fix a Blame Result That Points at an Automated Reformat Instead of the Real Change

- 26.09.26 - ErcanOPAK

🔀 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.

— Version Control Tip

Related posts:

Git: Use Git Bisect to Find Bugs with Binary Search

Git: Use Git Bisect to Find Bugs with Binary Search

Git Stash: Master Temporary Change Management

Git Stash: Master Temporary Change Management

The Hidden Cost of Large Commits (It’s Not Code Review)

The Hidden Cost of Large Commits (It’s Not Code Review)

Views: 10
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

JavaScript: Why a Set Still Contains ‘Duplicate’ Values That Look Completely Identical
Visual Studio: Fix a Watch Window That Shows a Stale Value for a Variable That Already Changed

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 869 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 672 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 585 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com