The way git store notes:
MainHash_2
), which is a tree object. Whenever you create a note the hash get changed. NOTES_2
) and one to parent tree object(the one in the the .git/refs/notes/ before creating this note, say MainHash_1
)As mentioned in third point why the parent is stored? As this parent(its type is same what is mentioned in point two) also contain another tree which contain one entry per note.
Suppose currently you have three notes. MainHash_2
contains a hash to NOTES_2
, which contain three entries for each note. MainHash_1
contains a hash to NOTES_1
, which contain two entries(for all the remaining notes except the one created now). Why storing these two entries twice and so on??
Simply because notes namespaces are not something special in git, they are just ordinary branches with complete history. You can do
git checkout notes/commits
and work with your notes as with any other branch, e.g. you can do
git log notes/commits
to see commit log for your notes. This way you can track all the changes to your notes.
You said that:
.git/refs/notes/commits
contains one hash (say,MainHash_2
), which is a tree object.
It's not a tree object, it's a commit. Just like in .git/refs/heads/master
. You can check it with git cat-file -t <hash>