Git stage - How to view a file including git-staged changes

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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?

Answers

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.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/18031172/how-to-view-a-file-including-git-staged-changes

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils