User Tools

Site Tools


git_show

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
git_show [2017/09/08 19:18]
rpjday
git_show [2019/02/24 08:15]
rpjday [The general form]
Line 1: Line 1:
-=== Overview ===+===== Overview ​=====
  
-The ''​git show''​ command ​has a number ​of interesting options.+The ''​git show''​ command ​can show various types of objects in various formats:
  
 +  * commits
 +  * trees
 +  * tags
 +  * blobs
  
-=== Showing ​a commit ​===+In addition, ''​git show''​ is used to show the state of repository contents as of given commit, or even as it is in the index at the moment.
  
-Regular usage:+===== Showing a commit ===== 
 + 
 +==== The regular way ====
  
 <​code>​ <​code>​
Line 48: Line 54:
 </​code>​ </​code>​
  
-''​--stat'' ​option:+==== The ''​--stat'' ​way ====
  
 <​code>​ <​code>​
Line 79: Line 85:
 </​code>​ </​code>​
  
-=== Showing a file ===+==== Extremely concise ====
  
-Showing ​the current ​file:+<​code>​ 
 +$ git show --oneline 
 +15d8ffc96464 (HEAD) Merge tag '​mmc-v4.14'​ of git://​git.kernel.org/​pub/​scm/​linux/​kernel/​git/​ulfh/​mmc 
 +
 +</​code>​ 
 + 
 +===== Showing ​files ===== 
 + 
 +==== The general form ==== 
 + 
 +<​code>​ 
 +$ git show <​commit>:<​filename>​ 
 +</​code>​ 
 +==== Showing some historical version of a file ==== 
 + 
 +Regardless of your current working directory, //show relative to the root of the repository//​:
  
 <​code>​ <​code>​
 $ git show HEAD:​Makefile $ git show HEAD:​Makefile
 $ git show master:​Makefile $ git show master:​Makefile
 +$ git show topic:​Makefile
 +$ git show v4.19:​Makefile
 +$ git show 2241b8bcf2b5f1b01ebb1cbd1231bbbb72230064:​Makefile
 </​code>​ </​code>​
  
-Showing ​an earlier ​file:+==== Showing ​file in the current directory ==== 
 + 
 +You need to use the ''​./''​ syntax:
  
 <​code>​ <​code>​
-$ git show v4.0:Makefile+$ cd scripts/ 
 +$ git show HEAD:​./​Makefile 
 +$ git show v4.19:./Makefile
 </​code>​ </​code>​
  
-Showing the index version of a file:+==== Showing the staged ​version of a file ==== 
 + 
 +If you leave off the commit part, you're referring to the index:
  
 <​code>​ <​code>​
 $ git show :Makefile $ git show :Makefile
 +$ git show :./Makefile
 </​code>​ </​code>​
git_show.txt · Last modified: 2019/02/24 08:17 by rpjday