Git blame showing no history Git blame showing no history git git

Git blame showing no history


git blame file.txt blames the version of file.txt in your working copy. If file.txt has Windows-newlines (CRLF) in the repo and you have core.autocrlf = true, then every line of file.txt will be considered different and will be reported by git blame as not yet committed.

The reason why git blame <my_branch> (or even better git blame HEAD, which works no matter what branch you're on) works, is that it doesn't blame the working copy version so there's no potential for lines not yet being committed.


Found the solution - very weird.

If I run this:

git blame file.txt

The history is broken, as posted above.

If I do this instead:

git blame my_branch file.txt

It works!

This is very weird, because AFAICS the usage doesn't require a branch name:

$ git blameusage: git blame [options] [rev-opts] [rev] [--] file


Starting git 2.0.1 (June 25th, 2014), git blame should stop reporting all those "Not Yet Committed" lines.

See commit 4d4813a (26 Apr 2014) by brian m. carlson (bk2204).
(Merged by Junio C Hamano -- gitster -- in commit e934c67, 06 Jun 2014)

blame: correctly handle files regardless of autocrlf

If a file contained CRLF line endings in a repository with core.autocrlf=input, then blame always marked lines as "Not Committed Yet", even if they were unmodified.
Don't attempt to convert the line endings when creating the fake commit so that blame works correctly regardless of the autocrlf setting.