Search code examples
gitgit-show

"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.


Solution

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

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