Search code examples
gitmacosversion-controlterminal

How to view git objects and index without using git


Using the OS X terminal,

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


Solution

  • Look at “Object storage format” in Git User Manual.

    It is raw compressed data using zlib. One can use zpipe from the 'zlib1g-dev' package. Compile the example with gcc -o zpipe zpipe.c -lz. It is not a standard .gz or something.

    ./zpipe -d < .git/objects/02/43019ddb4d94114e5a8580eec01baeea195133
    

    prints the content of the blob (header+data)

    If you want to check the SHA-1, you have to put the uncompressed blob in a file (myblob) and do

    sha1sum myblob