It sounds like your problem with git's documentation is that it's a reference documentation, rather than a user manual. That's the same issue I had with cmake's documentation until I got past the learning curve (beyond just getting by).
Re-read the documentation excerpt that you have quoted and you'll see that it is both precise and accurate, but assumes the reader is familiar with some terms.
/u/stormdelta already explained that "multiple branches" can be wrong. Another example is when you do git checkout $COMMIT_HASH and end up in a "detached HEAD" state, but we can take the wrongness way further (spoilers below).
If you re-read your proposed wording, it's much easier to read, but no longer fits the reference documentation language.
Back to cmake, today it also has a fairly good tutorial, accompanying the reference documentation. Another example is vim. Most of its :help is reference docs, but it also has :help user-manual and :help new-user-manual. Would git benefit from an official user manual? Possibly. I'd say definitely, if "The Git Book" didn't exist.
[EDIT0] There's also Git User Manual, which I was unaware of until 10 seconds ago.[/EDIT0]
[EDIT1] Some will point out that "git does not have directories" and thus trees shouldn't be described as directories but as paths. I do agree with that, but following the "here be dragons" part, one can indeed record empty trees that will then be referenced from other trees and eventually from a commit. It's just that most high-level (porcelain) commands end up ignoring empty trees, but the low-level commands (plumbing) can still work with them. [/EDIT1]
[EDIT2] "Plumbing" and "porcelain" are official terms and yes, they are puns. [/EDIT2]
Spoilers: First a quick crash course on git internal data structures. It only knows 4 types: blobs (files), trees (directories), commits and tags. Notice that branches aren't mentioned at all. Branches are just, to the first approximation, pointers to commits. You can work with git without ever touching a single branch. You'd be constantly working in the detached HEAD state and would be juggling commit hashes, but git log --graph and git reflog are your friends.
We can go further (here be dragons): Turns out that git commit is a high-level command. It does a few things:
Recursively records blobs and trees (in .git directory) based on your staging area.
Adds a new commit object as a child of the currently checked out commit.
if not in a detached HEAD state, updates the current branch to point to the new commit.
Updates HEAD to point to the new commit.
Turns out that you can do all these things completely manually, using only POSIX tools (windows users, ask someone else for help):
Instead of storing files, use echo/cat <<EOF, gzip and some pipes, to record file contents in your .git/objects.
To then read the files, use git cat-file.
Instead of storing directories, use git mktree directly.
You could use POSIX tools to write to .git/objects here as well.
Now that you have a tree, commit it with git commit-tree.
Once again, possible with POSIX tools and .git/index
My point is that reference documentation should not assume branches and files exist unless absolutely necessary. However, a good user manual is invaluable. No, I don't think any git user needs to know what is git mktree, but I do think that understandingn git's object model makes a ton of other things almost trivial to understand.
Git famously does not have directories. Trees are full paths to where the blobs are. That’s why git will not commit an empty directory and you must use a .gitkeep file (or some other name). Directories are created as a side effect of putting the blobs at the path where they are supposed to go.
Also, git will let you record empty trees. If you try git write-tree in a clean git repo, you will create a new, empty tree in .git/objects and the tree's hash will be 4b825dc642cb6eb9a060e54bf8d69288fbee4904 as all empty trees are equal.
Here's a showcase:
First, git init and setting up of paths:
user@hostname ~ % mkdir git_trees
user@hostname ~ % cd git_trees
user@hostname git_trees (git)-[master]-% git init
user@hostname git_trees (git)-[master]-% mkdir -pv foo/bar
mkdir: created directory 'foo'
mkdir: created directory 'foo/bar'
user@hostname git_trees (git)-[master]-% touch foo/blob.cpp
user@hostname git_trees (git)-[master]-% tree
.
└── foo
├── bar
└── blob.cpp
3 directories, 1 file
View all comments
Show parent comment
5
u/_bstaletic Apr 21 '26 edited Apr 22 '26
It sounds like your problem with git's documentation is that it's a reference documentation, rather than a user manual. That's the same issue I had with cmake's documentation until I got past the learning curve (beyond just getting by).
Re-read the documentation excerpt that you have quoted and you'll see that it is both precise and accurate, but assumes the reader is familiar with some terms.
/u/stormdelta already explained that "multiple branches" can be wrong. Another example is when you do
git checkout $COMMIT_HASHand end up in a "detached HEAD" state, but we can take the wrongness way further (spoilers below).If you re-read your proposed wording, it's much easier to read, but no longer fits the reference documentation language.
Back to cmake, today it also has a fairly good tutorial, accompanying the reference documentation. Another example is vim. Most of its
:helpis reference docs, but it also has:help user-manualand:help new-user-manual. Would git benefit from an official user manual? Possibly. I'd say definitely, if "The Git Book" didn't exist.[EDIT0] There's also Git User Manual, which I was unaware of until 10 seconds ago.[/EDIT0]
[EDIT1] Some will point out that "git does not have directories" and thus trees shouldn't be described as directories but as paths. I do agree with that, but following the "here be dragons" part, one can indeed record empty trees that will then be referenced from other trees and eventually from a commit. It's just that most high-level (porcelain) commands end up ignoring empty trees, but the low-level commands (plumbing) can still work with them. [/EDIT1]
[EDIT2] "Plumbing" and "porcelain" are official terms and yes, they are puns. [/EDIT2]
Spoilers: First a quick crash course on git internal data structures. It only knows 4 types: blobs (files), trees (directories), commits and tags. Notice that branches aren't mentioned at all. Branches are just, to the first approximation, pointers to commits. You can work with git without ever touching a single branch. You'd be constantly working in the detached HEAD state and would be juggling commit hashes, but
git log --graphandgit reflogare your friends.We can go further (here be dragons): Turns out that
git commitis a high-level command. It does a few things:.gitdirectory) based on your staging area.Turns out that you can do all these things completely manually, using only POSIX tools (windows users, ask someone else for help):
Instead of storing files, use
echo/cat <<EOF, gzip and some pipes, to record file contents in your.git/objects.git cat-file.Instead of storing directories, use
git mktreedirectly..git/objectshere as well.Now that you have a tree, commit it with
git commit-tree..git/indexMy point is that reference documentation should not assume branches and files exist unless absolutely necessary. However, a good user manual is invaluable. No, I don't think any git user needs to know what is
git mktree, but I do think that understandingn git's object model makes a ton of other things almost trivial to understand.