Domanda

enter image description here

From this picture, a commit is a pointer to the root tree which is a pointer to other trees and blobs. But what is a proper view of the index?

Questions:

  • Is it a similar tree-ish with folder structures or just a flat view of blobs?

  • If the index is a tree-ish, is there much difference between a commit and the index?

  • Does the index look more like a full snapshot or a diff?

È stato utile?

Soluzione

Altri suggerimenti

Conceptually, the index is a tree. It stores the state of HEAD reflecting all changes that have been made with git add. When the commit is made, the index simply becomes the tree in the commit. Are you maybe asking how the index is actually implemented? I would guess that it is indeed a tree, but I'm not certain.

Index is a collection of staging files. Or we can say all added files. Cache is the obsolete name of index which for me is easier to understand.

After you commit, the index becomes HEAD which is the head of current branch.

If you want to discard one file in index, you can use $git reset HEAD <filename> to do it.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top