Cyker
Cyker

Reputation: 10914

Git: What is the index

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:

Upvotes: 5

Views: 2366

Answers (3)

Alex
Alex

Reputation: 378

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.

Upvotes: 2

loganfsmyth
loganfsmyth

Reputation: 161457

Same answer as this question: Decoding Git index file using C#

The Git index file format is described here: http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/technical/index-format.txt;hb=HEAD

Upvotes: 2

Andy Ross
Andy Ross

Reputation: 12043

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.

Upvotes: 3

Related Questions