Hide formatting commits from git blame
One formatting commit and git blame credits it with every line it touched.
Published here , updated · 2 sources · Resume reading
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.
rm -rf /tmp/blame-demo && mkdir /tmp/blame-demo && cd /tmp/blame-demo
git init -q
git config user.email "[email protected]"
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.txtCaptured output (formatter owns both lines):
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]
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.txtCaptured output after config:
^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]
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]
git blame --ignore-rev "$FORMAT" demo.txtFrom 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
- Complete the mechanical format on its own commit (or a small series you are willing to skip forever).
git rev-parse HEAD(or each format SHA) into.git-blame-ignore-revs.- Commit the ignore file on
mainwith a message that names the formatter tool. - Document
git config blame.ignoreRevsFile .git-blame-ignore-revsfor developers on Git versions that do not auto-read the file (2.56 and older per project FAQ on this site). - 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:
# .git-blame-ignore-revs
a1b2c3d4e5f6789012345678901234567890abcd
f094c475da4fd9f8e74a4b6566606d478cdf0b52Git 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:
git -c blame.ignoreRevsFile= blame src/hot-path.tsThat 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.

Keep this guide
Filed under Dev tools
Questions about this guide
Does GitHub automatically read the ignore file?
Yes. GitHub's blame view reads .git-blame-ignore-revs automatically.
Do I need to configure Git locally?
Git 2.56 and older needs git config blame.ignoreRevsFile .git-blame-ignore-revs once per clone. Newer releases may read the file by default.
Sources
- GitHub docs: viewing and understanding filesdocs.github.com
- Git docs: git-blamegit-scm.com