# Hide formatting commits from git blame

> One formatting commit and git blame credits it with every line it touched.

Source: https://fullbytedeveloper.com/blog/blame-ignore
Published here: 2026-11-16, updated 2026-12-03

After a repo-wide format run, `git blame` often points at the formatting commit for every touched line, hiding the author who wrote the logic. List those SHAs in `.git-blame-ignore-revs` so blame walks past them to the last substantive change. GitHub reads the file in the web UI; local Git needs a config flag on many versions. [1][2]

## Reproduce the problem in a throwaway repo

The sequence below uses a fresh repository under `/tmp`. Alice adds content; a second commit only changes whitespace.

```bash
rm -rf /tmp/blame-demo && mkdir /tmp/blame-demo && cd /tmp/blame-demo
git init -q
git config user.email "alice@example.com"
git config user.name "Alice"
printf 'line one\nline two\n' > demo.txt
git add demo.txt && git commit -q -m "Alice content"
printf 'line one  \nline two  \n' > demo.txt
git add demo.txt && git commit -q -m "chore: whitespace format"
FORMAT=$(git rev-parse HEAD)
git blame demo.txt
```

Captured output (formatter owns both lines):

```text
f094c475 (Alice 2026-12-03 11:11:57 +0000 1) line one  
f094c475 (Alice 2026-12-03 11:11:57 +0000 2) line two  
```

That is the UX problem: code review and archaeology show "chore: whitespace format" instead of the feature commit.

## Wire up `.git-blame-ignore-revs`

Add one full SHA per line. Comments starting with `#` and blank lines are allowed per `git blame` docs. [2]

```bash
echo "$FORMAT" > .git-blame-ignore-revs
git add .git-blame-ignore-revs
git commit -q -m "Track ignored format revs"
git config blame.ignoreRevsFile .git-blame-ignore-revs
git blame demo.txt
```

Captured output after config:

```text
^72f0d74 (Alice 2026-12-03 11:11:57 +0000 1) line one  
^72f0d74 (Alice 2026-12-03 11:11:57 +0000 2) line two  
```

The caret marks a boundary commit; both lines trace back to Alice's content commit again. Committing the ignore file alone does not change terminal blame until `blame.ignoreRevsFile` points at it (on Git 2.43.0 in this environment). [2]

<figure>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 260" role="img" aria-label="git blame skips SHA listed in git-blame-ignore-revs and attributes the prior commit">
  <defs>
    <marker id="arrowBlameIgnore" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto">
      <path d="M0,0 L8,3 L0,6 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="720" height="260" rx="12" fill="#0b1f3a"/>
  <text x="24" y="36" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="16" font-weight="700">git blame one line</text>
  <rect x="24" y="52" width="150" height="56" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="36" y="84" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">line in working tree</text>
  <path d="M174 80 H222" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowBlameIgnore)"/>
  <rect x="230" y="52" width="170" height="56" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="242" y="84" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">last modifying commit</text>
  <path d="M400 80 H448" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowBlameIgnore)"/>
  <rect x="456" y="44" width="180" height="72" rx="8" fill="#123052" stroke="#f59e0b" stroke-width="2"/>
  <text x="468" y="72" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">format commit</text>
  <text x="468" y="96" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">SHA in ignore file</text>
  <path d="M546 116 V148" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowBlameIgnore)"/>
  <path d="M546 148 H120" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowBlameIgnore)"/>
  <path d="M120 148 V176" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowBlameIgnore)"/>
  <rect x="24" y="184" width="280" height="56" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="36" y="216" fill="#14b8a6" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">prior substantive author</text>
  <rect x="320" y="184" width="376" height="56" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="332" y="216" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">GitHub UI reads .git-blame-ignore-revs; local Git needs blame.ignoreRevsFile on older versions [1][2]</text>
</svg>
</figure>

*Ignored format SHAs are transparent to blame; attribution walks back to the commit that last changed meaning, not whitespace.*

## GitHub blame without extra setup

GitHub's file viewer documentation states that blame reads `.git-blame-ignore-revs` in the repository root automatically, so teammates see the same skipped revisions in the browser once the file is on the default branch. [1]

Push the ignore file before you announce the format policy. Otherwise the web blame and local blame disagree until everyone configures Git.

## One-off blame for a single SHA

`git blame` accepts `--ignore-rev` and `--ignore-revs-file` on the command line without touching config. [2]

```bash
git blame --ignore-rev "$FORMAT" demo.txt
```

From the same demo repo, that matched the configured blame output (both lines attributed to the content commit). Use this when you are browsing someone else's clone before you set `blame.ignoreRevsFile`.

## What Git documents about ignored revisions

The `git blame` manual says `--ignore-rev` treats the change as if it never happened for attribution, and lines touched only by ignored commits fall back to the previous commit that modified them. `--ignore-revs-file` reads the same SHA list format as `blame.ignoreRevsFile`. Git 2.56.0 release notes (per the doc's version list) continue to evolve blame behavior; check `git --version` when docs and behavior diverge. [2]

Optional porcelain markers: when `blame.markIgnoredLines` is set, lines moved from an ignored commit may show `?`; unblamable lines can show `*`. Most teams never enable those; the default human output is enough.

## Team rollout checklist

1. Complete the mechanical format on its own commit (or a small series you are willing to skip forever).
2. `git rev-parse HEAD` (or each format SHA) into `.git-blame-ignore-revs`.
3. Commit the ignore file on `main` with a message that names the formatter tool.
4. Document `git config blame.ignoreRevsFile .git-blame-ignore-revs` for developers on Git versions that do not auto-read the file (2.56 and older per project FAQ on this site).
5. Confirm GitHub blame on one hot file matches local blame after step 4.

For large monorepos, keep one ignore list at the root unless a subtree uses a separate policy; GitHub expects the root filename. [1]

## Multiple format waves

Big repos sometimes run Prettier in 2019, ESLint `--fix` in 2022, and Biome in 2026. Each wave can add another SHA on its own line:

```text
# .git-blame-ignore-revs
a1b2c3d4e5f6789012345678901234567890abcd
f094c475da4fd9f8e74a4b6566606d478cdf0b52
```

Git processes the file after any `blame.ignoreRevsFile` config and after repeated `--ignore-revs-file` flags on the command line. [2] Keep comments that name the tool so future maintainers do not delete a SHA thinking it is orphaned.

When two format commits touch the same lines in one branch, blame walks back through both ignored revisions in order. If you accidentally list a feature commit, blame will skip real history; audit the diff with `git show <sha> --stat` before adding it.

## Compare with other blame flags

`-w` asks Git to ignore whitespace when matching lines to parents. It helps on small diffs but does not remove a whole formatting commit from attribution. `-C` and `-M` follow moved code across files; they complement ignore revs but do not replace them when a mass format touched thousands of files unchanged in meaning. [2]

For bisecting a regression, temporarily disable the ignore file:

```bash
git -c blame.ignoreRevsFile= blame src/hot-path.ts
```

That shows the raw timeline when you suspect the formatter hid a bad intermediate commit (rare, but useful once).

## Mistakes with blame ignore files

Short SHA in the ignore file: use `git rev-parse` full hashes. Ambiguous abbreviations break silently or match the wrong object. [2]

Ignore commits that also changed logic and blame will skip real bug introductions. Keep the list formatting-only; split mixed "format + refactor" work into two commits before you ignore anything. [2]

New clones still show raw terminal blame on older Git until someone runs `git config blame.ignoreRevsFile .git-blame-ignore-revs`, even when GitHub blame already looks correct. [1]

Divergent ignore lists on release branches confuse archaeology. Merge `.git-blame-ignore-revs` like any shared policy file.

Ignore revs change attribution in blame only. The format commit still appears in `git log -p` and in bisect timelines. [2]

`git blame -w` ignores whitespace when matching lines to parents; it does not skip a whole formatting commit. Use `-w` and ignore-revs together when older whitespace-only commits sit outside the SHA you listed. [2]

## Editor and CI habits that keep the list honest

Run the formatter in CI as a check (`prettier --check`, `ruff format --check`) so day-to-day commits never need a second mega format. The ignore file is for the rare mechanical wave you already landed, not for weekly style thrash.

When you must reformat, open a PR titled for the tool and version, touch no behavior, and paste the SHAs into `.git-blame-ignore-revs` in a follow-up commit on the same PR when possible. Reviewers can then approve "format only" without arguing about who owns every line in blame afterward.

If a teammate already reformatted `main` without an ignore file, add the SHA now. Blame does not require the ignore entry to have existed at format time; it only needs the file present when you run blame today. [1][2]

## Prove GitHub and local agree on one file

Pick a file the formatter touched heavily. On GitHub, open Blame and note the author on a mid-file line. Locally, with `blame.ignoreRevsFile` set, run `git blame -L <line>,<line> -- path`. The author and substantive commit subject should match. If GitHub skipped the format SHA and your laptop still shows it, the local config path is wrong or the ignore file is not on the commit you checked out.

Send this to the friend who ran Prettier on main and now owns every line in blame.

Image: A blame timeline of commit slabs behind a row of code-line bars, with a wide formatting slab faded behind a translucent ignore-filter plane so earlier true-author colors show through on the lines, rendered with no typography, avatars, or figures.
https://fullbytedeveloper.com/media/blame-ignore/blame-ignore-venice.webp
A formatting commit can cover every line it touched. An ignore list can see through it.

## Sources

1. [GitHub docs: viewing and understanding files](https://docs.github.com/en/repositories/working-with-files/using-files/viewing-and-understanding-files)
2. [Git docs: git-blame](https://git-scm.com/docs/git-blame)
