How to view git objects and index without using git

后端 未结 5 2291
情歌与酒
情歌与酒 2020-12-29 07:13

Using the OS X terminal,

How an you view the contents of these files as plain text?

5条回答
  •  心在旅途
    2020-12-29 07:54

    I'm going to interpret your question in a different way. If you want to understand what the objects files ARE, you can use git to view them directly, without navigating the history log or using git checkout, diff etc. For instance:

    For the file .git/objects/04/a42e9a7282340ef0256eaa6d59254227b8b141

    Run the command

    git show 04a42e
    

    which combines the 04 from /04/ and the first four characters of the remaining number a42e.

    > git show 04a42e
    commit 04f7db976fa54c72fcc6350dd7d0aa06cb249df6
    Author: Alex Brown 
    Date:   Fri Jan 8 11:02:21 2010 +0000
    a text file
    
    diff --git a/1.txt b/1.txt
    new file mode 100644
    index 0000000..04a42e9
    --- /dev/null
    +++ b/1.txt
    @@ -0,0 +1,3 @@
    +Woo
    +# boo
    +# choo
    

    This one is a commit, other objects may be file blobs, trees, etc.

提交回复
热议问题