1

I'm trying to show the contents of a file in a specific commit, this is the command I'm using:

git show ($commit)^:($filename)

However, it's showing contents of the previous commit. I'm not sure if this command is supposed to get the contents "before" the commit, or if it's because the commit I specified was for reverting the previous commit.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
nancyheidilee
  • 322
  • 1
  • 2
  • 10

1 Answers1

2

The ^ operator means "the ancestor of the given commit". Just remove it, and you should be fine:

$ git show ($commit):($filename)
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • 1
    One side note: it's a *suffix* hat `^` (followed by an optional number, default `1`) that means "parent". A prefix `^` here is invalid but in other contexts, the prefix hat operator means "not". – torek Oct 27 '16 at 02:27