What does the git index contain EXACTLY?

后端 未结 6 1403
谎友^
谎友^ 2020-11-22 17:28

What does the Git index exactly contain, and what command can I use to view the content of the index?


Update

Thanks for all your answe

6条回答
  •  醉酒成梦
    2020-11-22 17:36

    Git index is a binary file (generally kept in .git/index) containing a sorted list of path names, each with permissions and the SHA1 of a blob object;

    git ls-files can show you the contents of the index. Please note that words index, stage, and cache are the same thing in Git: they are used interchangeably.

    Git index, or Git cache, has 3 important properties:

    1. The index contains all the information necessary to generate a single (uniquely determined) tree object.
    2. The index enables fast comparisons between the tree object it defines and the working tree.
    3. It can efficiently represent information about merge conflicts between different tree objects, allowing each pathname to be associated with sufficient information about the trees involved that you can create a three-way merge between them.

    Source:

    1. https://mincong.io/2018/04/28/git-index/
    2. https://medium.com/hackernoon/understanding-git-index-4821a0765cf

提交回复
热议问题