How does Git know which Index blob to add to a tree?
- by drozzy
In Pro Git Ch9 the author says:
Git normally creates a tree by taking the state of your staging area or index and writing a tree object from it.
My question is how does git know which of two consequitive index entries to create the Tree object from?
For example:
$ echo 'First change' > one.txt
$ git add one.txt
$ find .git/objects -type f
.git/objects/1f/755a7fffe4 //first index entry
$ echo 'Second change' > one.txt
$ git add one.txt
$ find .git/objects -type f
.git/objects/2d/234asdf2 //second index entry
$ git commit -a -m "Initial commit"
$ git cat-file master^{tree}
100644 blob 2d234asdf2 one.txt //How did it know not to take 1f755??
Does it just look at the blob timestamps?
Also - what happens to the first blob created - no one is referencing it. Does it just get destroyed or forgotten?