1

I'm working on staging some modified content to the index, and I'd like to see how the previous commit looks without stashing. I am aware of git stash's --keep-index option, but would rather not stash if possible. Is this possible?

Dmitry Minkovsky
  • 36,185
  • 26
  • 116
  • 160
  • possible duplicate of [Is there a quick git command to see an old version of a file?](http://stackoverflow.com/questions/338436/is-there-a-quick-git-command-to-see-an-old-version-of-a-file) –  Sep 02 '13 at 12:00
  • The answer I provide is among the answers to that question, but I think my question itself is different as it relates to stashing. – Dmitry Minkovsky Sep 02 '13 at 13:50
  • @dimadima but it doesn't relate to stashing... – hobbs Dec 26 '13 at 06:19
  • @hobbs: it relates to _not_ stashing. anyway, take it or leave it :). vote dupe if you want to close it. i had wanted to create an easily google-able Q/A after not easily finding the answer to this myself. – Dmitry Minkovsky Dec 26 '13 at 06:24

1 Answers1

4

Try:

git show :path/to/file

That is, git show with a : prepended to the path of the file you want to see.

This behavior is described in the gitrevisions manpage.

Dmitry Minkovsky
  • 36,185
  • 26
  • 116
  • 160
  • 1
    `cat-file -p` does the same. You could also `git diff HEAD -- path/to/file` (allthough that strictly gives you a diff, not the original file) – sehe Sep 02 '13 at 09:33
  • @dimadima what is it that you find confusing? –  Sep 02 '13 at 11:59
  • @Cupcake: A bunch of things. It's nearly impossible to read non-linearly. And non-linearity aside, take this for example: "A colon, optionally followed by a stage number (0 to 3) and a colon". Nowhere else in the manpage is a "stage number" mentioned. And I've never heard of "stage number" within the context of Git altogether, actually. – Dmitry Minkovsky Sep 02 '13 at 13:54