I am in a repository where git blame has effectively been broken.
There are two commits I want to ignore in git blame.
- Commit 1 destroyed a lot of files.
- Commit 2 immediately reverted commit 1.
Every time I git blame a line now I see the author of [commit 2] instead of the true logical author.
I end up having to do a git log [file in question]
instead, or another one of the solutions listed in this question.
These two commits make me sad whenever I use the Annotate feature in Intellij (which is basically git blame).
Has anybody ever fixed this problem before without rewriting history?
if it were really immediately reverted, you can use
git replace --edit $comment2
to fake parent of commit1 to be its parent.Before Q3 2019, no.
But with Git 2.23, you will be able to instruct git blame to ignore those two problematic commits. (IntelliJ "annotate" feature might take a while before catching up)
Michael Platings comments though:
That being said,
git blame
can now ignore commits (even maybe not in this particular case).In general, since Git 2.23:
"
git blame
" learned to "ignore" commits in the history, whose effects (as well as their presence) get ignored.And you can register that in your
git config
! You don't even need to pass those commits in parameters on everygit blame
call.See commit 78fafbb (30 Jun 2019), and commit 1d028dc (20 Jun 2019) by Michael Platings (``).
See commit 07a54dc (28 Jun 2019) by Jeff King (
peff
).See commit f0cbe74, commit a07a977 (20 Jun 2019), and commit 1fc7338, commit 8934ac8, commit ae3f36d, commit 55f808f, commit f93895f, commit 24eb33e (15 May 2019) by Barret Rhoden (
brho
).(Merged by Junio C Hamano --
gitster
-- in commit 209f075, 19 Jul 2019)git blame
new documentation:git config
new documentation:Since the line detection is not always perfect:
That means the
git config
man page now has:Finally, to improve the
git blame
line detection: