gitgit-svninternalsgit-notes

Why parent is stored in git notes?


The way git store notes:

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??


Solution

  • 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>