git: index, working

Knowing the concepts behind git really helps use it productively. It’s an incredibly complex system. Why? ‘cos it’s more powerful than any other system and got a ton of features that you’ll never use but also it’s got a bunch of nonstandard names for things (VCSs (version control systems) use names like ‘checkout’ and ‘revert’ – not git!). Finally, the index.

The basics:

1. Think of git not as a VCS but rather as a distributed versioned file system

2. You can get by using git without the index. Just pretend it’s a faster implementation of Subversion, works offline, with better branches and merging. 

i.e. if you use “git commit -a” instead of “git commit” you can ignore the index completely.

The git data stores are:

  • workspace
  • index
  • local repository (repo)
  • remote repository (repo)

VCS’ tend to have a workspace and a remote repo. git adds an index and a local repo.

Take a look at the diagram below:

 

“git add” causes the index to diverge from the workspace. What’s the point of this index? 

As git is a distributed versioned, it has a VCS layer on top. This layering lets you build your own workflows. Some of these workflows involve the index.

See also:

http://stackoverflow.com/questions/3689838/difference-between-head-working-tree-index-in-git

and the workflow post here:

http://osteele.com/posts/2008/05/my-git-workflow

Leave a Reply

Your email address will not be published. Required fields are marked *