문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

$ git ls-files --cached --stage
100644 f009acdec84ee338ec99c92920d603a67241608f 0       README

Guest@HOME-PC ~/doubt (master)
$ git cat-file -p f009acdec84ee338ec99c92920d603a67241608f

One
Teo
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top