Could you explain the difference between git show test.rb
and git show HEAD:test.rb
?
The command git show HEAD:test.rb
returns:
test file contents
while git show test.rb
returns:
commit a8e90b3dbf4eed03cdbb3cd3b99f98e9153c7219
Author: Misha Moroshko <[email protected]>
Date: Thu Oct 27 17:03:04 2011
+1100
asd
diff --git a/test.rb b/test.rb new file mode 100644 index
0000000..b48e119
--- /dev/null
+++ b/test.rb @@ -0,0 +1 @@
+test file contents
git show
for commits will show the log message and textual diff. So that is what you get when you dogit show
, with the commit being assumed to be HEAD. Andgit show file
shows the log message and textual diff for HEAD, filtered tofile
.To show the content of the files at a particular commit, you do
git show commit:file
. So thegit show HEAD:file
shows the contents of the file in HEAD.From
gitrevisions
man page:Also refer to the examples in the git show manual (
git show --help
)