How to view git objects and index without using git

后端 未结 5 2281
情歌与酒
情歌与酒 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 08:00

    The index is stored under .git/index.

    It is a binary uncompressed format specified at: https://github.com/git/git/blob/master/Documentation/technical/index-format.txt, so the only way to read it is with a tool like hd.

    The index file contains a list of files with their metadata, including inode, permissions, and modification time. It also contains the SHA-1 of the content, which is stored as an object, which means that when you do git add it may create new objects.

    I encourage you to create a simple test repo like git init init && cd init && echo a > a && git add a, and then hd .git/index to verify the format field by field.

    The following question focuses more on the index: What does the git index contain EXACTLY?

提交回复
热议问题