-1

A Git repository can be viewed as a database.

Does Git index have similar purpose of database index, given they are both named "index"? (I can't figure out any relation between them, but I don't know much.)

halfer
  • 19,824
  • 17
  • 99
  • 186
Tim
  • 1
  • 141
  • 372
  • 590
  • 1
    They have no relation in any way AFAIK. The Git index is a logical place where certain files (and their underlying blobs and plumbing) are placed before a new commit is made in a Git branch. A database index is an ordered data structure, usually a B-tree, which represents a portion of data in a table in a certain order. So, not much in common here. – Tim Biegeleisen Jan 17 '19 at 13:41
  • I've never liked the word "index" for the Git index. It's a staging area, and nothing like any of the senses of the word "index" I can find in a dictionary or elsewhere in computer science. – joanis Jan 17 '19 at 13:49
  • what is the most accurate computer science and system term to name git index? – Tim Jan 17 '19 at 13:50
  • Possible duplicate of [What's the difference between HEAD, working tree and index, in Git?](https://stackoverflow.com/questions/3689838/whats-the-difference-between-head-working-tree-and-index-in-git) – JDB Jan 17 '19 at 16:47
  • As @joanis said, "index" is a poor choice of name for this Git-specific data structure. *Staging area* and *cache* are better names, but still not great as Git's index has aspects of both. Git could perhaps call it "the Git mishmash" and be less confusing. :-) – torek Jan 17 '19 at 19:22
  • @Tim: I'd vote for "staging area" as the best term. – joanis Jan 17 '19 at 21:33
  • I just realized, there is a sense in which the Git index is indeed an index: the index data structure is basically a list of file-names and the staged blobs for those files. So it is the index for the current staging area, thus not so poorly named after all. – joanis Jan 18 '19 at 15:23

1 Answers1

1

The 'commit hash' in Git has a closer relation to an 'index' in database terminology.

An 'index' in Git has a totally different meaning. An index is the differences between the last commit and the changes you've 'staged' for the next commit.

benhorgen
  • 1,928
  • 1
  • 33
  • 38