git がやっていることの意味 (index の意味) を理解するには git add と git commit は別々にやったほうがいいかもしれない。
command | HEAD | index (stage) | WORK_TREE | |||
---|---|---|---|---|---|---|
blob-hash | file | blob-hash | file | blob-hash | file | |
$ git init; | ||||||
$ echo foo.txt >> foo.txt; | 7c6ded1 | foo.txt | ||||
$ echo bar.txt >> bar.txt; | 7c6ded1 | foo.txt | ||||
e5dbdfd | bar.txt | |||||
$ git add foo.txt bar.txt; | 7c6ded1 | foo.txt | 7c6ded1 | foo.txt | ||
e5dbdfd | bar.txt | e5dbdfd | bar.txt | |||
$ git commit --message="update"; | 7c6ded1 | foo.txt | 7c6ded1 | foo.txt | ||
e5dbdfd | bar.txt | e5dbdfd | bar.txt | |||
$ echo bar.txt >> bar.txt; | 7c6ded1 | foo.txt | 7c6ded1 | foo.txt | ||
e5dbdfd | bar.txt | 9219c9a | bar.txt | |||
$ git add bar.txt; | 7c6ded1 | foo.txt | 7c6ded1 | foo.txt | ||
e5dbdfd | bar.txt | 9219c9a | bar.txt | 9219c9a | bar.txt | |
$ git commit --message="update"; | 7c6ded1 | foo.txt | 7c6ded1 | foo.txt | ||
9219c9a | bar.txt | 9219c9a | bar.txt |