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
The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.
The Git status command gives us all the necessary information about the current branch.
To determine whether a file has changed, Git compares its current stats with those cached in the index. If they match, then Git can skip reading the file again. Since stat calls are considerably faster than file reads, if you only edit a few files, Git can update its state in almost no time.
On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With