gitpowershellposh-git

git blame throws a bad revision error with the -L <n,m> option


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?


Solution

  • 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.

    git blame -L 10, 200 composer.json 
    
    fatal: bad revision '200'
    

    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.