nancyheidilee nancyheidilee - 1 month ago 7
Git Question

"git show" command showing previous commit

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.

Answer

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

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