User Tools

Site Tools



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
git_show [2018/02/11 12:21]
rpjday [The ''--stat'' way]
git_show [2019/02/24 08:17] (current)
rpjday [Showing the staged version of a file]
Line 1: Line 1:
 ===== Overview ===== ===== Overview =====
-The ''​git show''​ command ​has a number ​of interesting variations.+The ''​git show''​ command ​can show various types of objects in various formats:
 +  * commits
 +  * trees
 +  * tags
 +  * blobs
 +In addition, ''​git show''​ is used to show the state of repository contents as of a given commit, or even as it is in the index at the moment.
 ===== Showing a commit ===== ===== Showing a commit =====
Line 87: Line 93:
 </​code>​ </​code>​
-===== Showing ​a file =====+===== Showing ​files =====
-==== Showing some version of a root directory file ====+==== The general form ====
-Regardless of your current working directory:+<​code>​ 
 +$ git show <​commit>:<​filename>​ 
 +==== Showing some historical version of a file ==== 
 +Regardless of your current working directory, //show relative to the root of the repository//​:
 <​code>​ <​code>​
Line 97: Line 108:
 $ git show master:​Makefile $ git show master:​Makefile
 $ git show topic:​Makefile $ git show topic:​Makefile
-$ git show v4.12:Makefile+$ git show v4.19:​Makefile 
 +$ git show 2241b8bcf2b5f1b01ebb1cbd1231bbbb72230064:Makefile
 </​code>​ </​code>​
 ==== Showing a file in the current directory ==== ==== Showing a file in the current directory ====
 +You need to use the ''​./''​ syntax:
 <​code>​ <​code>​
 +$ cd scripts/
 $ git show HEAD:​./​Makefile $ git show HEAD:​./​Makefile
-$ git show v4.12:./Makefile+$ git show v4.19:./Makefile
 </​code>​ </​code>​
 ==== Showing the staged version of a file ==== ==== Showing the staged version of a file ====
 +If you leave off the commit part, you're referring to the state of the file in the index:
 <​code>​ <​code>​
git_show.1518351688.txt.gz · Last modified: 2018/02/11 12:21 by rpjday