Git Reference ยท Files and Formats
The .git-blame-ignore-revs file
Reference for the .git-blame-ignore-revs file: list bulk reformatting commits and make git blame skip them with blame.ignoreRevsFile or --ignore-revs-file.
After a project-wide reformat, rename or lint fix, git blame blames that one commit for almost every line, which makes it useless. An ignore-revs file lists such commits, one object ID per line, and tells git blame to look past them and attribute each line to the last commit that changed its meaning.
The conventional file name is .git-blame-ignore-revs in the repository root. Git does not read it by itself: you point blame.ignoreRevsFile at it (or pass --ignore-revs-file). GitHub, GitLab and several editors detect the conventional name automatically.
git config blame.ignoreRevsFile .git-blame-ignore-revs git blame --ignore-revs-file .git-blame-ignore-revs <file>
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
# comment <full object ID> <full object ID>
| Setting or option | Description |
|---|---|
blame.ignoreRevsFile |
Path of a file to read; can be set several times. An empty value clears the list. A missing file is an error. |
--ignore-revs-file <file> |
Same, for one run. Use an empty value to clear configured files. |
--ignore-rev <rev> |
Ignore one commit given on the command line. |
blame.markIgnoredLines |
Prefix lines whose blame changed because of an ignored commit with ?. |
blame.markUnblamableLines |
Mark lines that could not be attributed with *. |
File format: one hexadecimal object ID per line (use full IDs; abbreviations are not accepted). Blank lines are skipped. Anything after # is a comment.
Edge cases: lines that existed only in the ignored commit are blamed on the commit's parent as a best guess, and may be marked unblamable.
Usage notes
- Commit the file. Put it in the repository and add a short comment above each ID naming what the commit did. Then document
git config blame.ignoreRevsFile .git-blame-ignore-revsin your README, since clones do not get the setting automatically. - Append only after merging. Record the real hash from the main branch. Squash and rebase merges change hashes, so list the final commit, not the one on your branch.
- Heuristic. Blame guesses by matching lines in the parent; unusual reformatting may still attribute lines to the style commit.
- Not a rewrite. It changes only what blame shows. History and
git logstay intact. - Works with editors and hosts. GitHub's blame view honors a file with this exact name; other tools usually use
git blameand so need the config. - Merge commits. The ignore applies to the commit you name. Listing a merge does nothing unless its changes appear as its own diff.