gitgit-show

Why does git show filename display a diff?


git show filename diplays a diff, while git show branch:path/to/filename displays the content of the file.

I look in the help (git show --help) and what I understood is that it should default to HEAD, i.e. git show HEAD:filename.

But that produces the content of the file as I expected. Does anyone have any insight?


Solution

  • git show <path> is equivalent to git show HEAD <path>.

    Without <path>, it prints the log message and the diff of changed files of the head commit.

    With <path>, it prints the log message and the diff of the specified path of the head commit if the file is changed in the commit. If not, nothing is printed.