Snowcrash
Snowcrash

Reputation: 86317

What does `git show` do all by itself?

If I use git show all by itself in a git repo it shows a bunch of information such as commits, diffs, etc.

This page (https://git-scm.com/docs/git-show) just says:

Shows one or more objects (blobs, trees, tags and commits).

I assume it's the latest commit. And some diffs (which aren't mentioned in the docs page).

But what exactly is it showing?

Here's the full, rather incomprehensible, output...

$ git show
commit <sha1 A> (HEAD -> A)
Merge: <sha1 B> <sha1 C>
Author: Snowcrash <my@email>
Date:   Sat Jul 14 14:56:02 2018 -0700

    with both files

diff --cc 1
index <sha1 D>,<sha1 E>..<sha1 F>
--- a/1
+++ b/1
@@@ -1,5 -1,6 +1,12 @@@
  1

++<<<<<<< HEAD
 +A
 +B
 +C
++=======
+ C
+ D
+ E
+
++>>>>>>> master
diff --cc 2
index 0000000,0000000..<sha1 G>
new file mode 100644
--- /dev/null
+++ b/2
@@@ -1,0 -1,0 +1,1 @@@
++2

Upvotes: 16

Views: 23860

Answers (2)

Rory O&#39;Kane
Rory O&#39;Kane

Reputation: 30418

As emlai wrote, git show describes the HEAD commit by default. As for what it shows about the HEAD commit, the git-show manual page describes the output:

For commits it shows the log message and textual diff. It also presents the merge commit in a special format as produced by git diff-tree --cc.

At least for non-merge commits, this output is the same as the output from git log --cc HEAD~..HEAD. The --cc flag causes the diff to be shown.

Upvotes: 8

flogram_dev
flogram_dev

Reputation: 42868

git show is equivalent to git show HEAD, i.e. the latest commit in the current branch (more info).

Source: https://github.com/git/git/commit/9f5258cbb8f8ed2bf86b0078f178a26adc572eb9

Upvotes: 9

Related Questions