LetsPlayYahtzee
LetsPlayYahtzee

Reputation: 7611

How to "revive" git blame history

I find myself in a precarious situation.

I work on refactoring a big, existing codebase. I decided to comment out some tests and enable them gradually as I adapt the code. Unfortunately, I committed the commenting-out and now the git blame history of a complete test module shows me as the author of the last change. My only committed contribution to this code is two commits (commenting and uncommenting) - unfortunately the first ones comes with changes in other places I want to keep.

I am not knowledgeable in git enough to know if there is a relatively easy way to correct the git history to showing the author of the previous state of the code (prior to my commenting out).

Is starting from scratch my only option?

Upvotes: 2

Views: 1021

Answers (1)

torek
torek

Reputation: 489748

Modern git blame takes arguments to tell it: don't blame this revision. See the --ignore-rev and --ignore-revs-file options. Your simplest path will be to list your own commits in some file and use --ignore-revs-file.

If your git blame is too old, consider upgrading Git; if that's not possible, note that git blame starts from (and then works backwards from) any specified revision, so you can simply pick some revision before your change.

Upvotes: 2

Related Questions