How to view a file including git-staged changes

git, git-stage

Solution

You can view the staged version of a file using:

git cat-file -p :./FILENAME

The leading `:` causes git to read from the index. The `./` gets it to look in the current directory, this part may be omitted if you specify a path relative to the top of the repository rather than to your current directory.

You can view a specific subset of lines by piping the output from that to another command to do the desired limiting as for any other file.

Problem

git diff --staged allows you to view changes between HEAD and the staged changes. How do I view the full file as it would exist in HEAD if I were to commit the staged changes? How do I view a specific subset of lines from it?

Original source