Re: [PATCH] doc: add a explanation of Git's data model
From: Julia Evans <hidden>
Date: 2025-10-09 13:21:14
quoted
quoted
quoted
I think I'll see if I can figure out a way to mention this and at the same time remove most of the rest of the references to the `.git` directory when explaining references (which you talked about further down), including packed refs.A colleague will be explaining reflog for an audience tomorrow, and decided to briefly explain refs, too—which tells me this is much-needed. For refs themselves, perhaps "git for-each-ref" is a reasonable place to start? Since it tells you the refs you have and how to spell them explicitly regardless of how they are stored?Interesting, do you use git for-each-ref? What do you use it for?Ah, yes, but primarily for scripting. What I should have clarified is that "the tool (I know of) to interrogate the refs you currently have is git-for-each-ref" (like how git-ls-remote is the tool to interrogate a remote's refs). It avoids the issues with assuming "tree .git/refs" or similar will capture the actual data.
Ah, that makes sense! I spent a little while trying to come up with something that would give a "similar result" to running `cat .git/<refname>` and I came up with this: git for-each-ref <ref-name> --include-root-refs --format="%(refname) %(if)%(symref)%(then)%(symref)%(else)%(objectname:short)%(end)" I hoped to find a simple equivalent to that `cat` command (kind of the equivalent of `git cat-file -p`) that would work with other ref backends but couldn't find one.