How do I run a code formatter over my source without modifying git history?

You can make git blame ignoring certain commits, which do only mass reformatting etc.:

Create a file .git-blame-ignore-revs like:

 # Format commit 1 SHA:
 1234af5.....
 # Format commit 2 SHA:
 2e4ac56.....

Then do

git config blame.ignoreRevsFile .git-blame-ignore-revs

, so that you don’t have to use the --ignore-revs-file option every time with git blame.

Upvote https://github.com/github/feedback/discussions/5033 to get that feature into github’s web blame viewer.

Leave a Comment