git blame throws a bad revision error with the -L option

Question:

One of the git blame options processes a line range. The manual says:

-L Process only line range n,m, counting from 1

Now, I have a file that has over 100 lines. When I run git blame -L 5,15 myFile.txt, git complains:

fatal: bad revision ’15’

Interestingly, git does not complain when I run git blame -L 5 myFile.txt.

What’s going on?

Answer:

Your command looks correct in that case.

I have checked that problem with my composer.json file, and it’s working well. When I try to access more lines than are inside the file, I get an error “file composer.json has only 87 lines”.

You get this error only if you have a space before the second value.

So I think that’s the problem.

Note that PowerShell and/or Posh-Git might inject a space after the comma. Try using the command prompt.

Source:

git blame throws a bad revision error with the -L option by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply