3 ms·
Yes it does, it just doesn't store empty directories.
by remram 1y ago
Yes it does, it just doesn't store empty directories.
- juped 1y agoYou can perfectly easily put the empty tree object as a tree object's child, this just isn't supported and some parts of Git will break.
- lucasoshiro 1y agoIt can store empty directories (actually, trees). It can't do normally because the index maps paths to blobs, an empty directory doesn't have a file to map to a blob and then `git add` will have no effect. Given that normally we write commits from the index content, then normally we won't find an empty tree. You can run `git commit --allow-empty` with an empty index and the root tree will be the empty tree: $ git init $ git commit --allow-empty -m foo $ git rev-parse @^{tree} 4b825dc642cb6eb9a060e54bf8d69288fbee4904 4b825dc is the empty tree. And a funny thing about it is that it is hardcoded in Git, and you can use it without having this object: $ git init $ git commit-tree -m foo 4b825dc642cb6eb9a060e54bf8d69288fbee4904 $ tree .git/objects # you'll see that there's no file for the empty tree This is a good reading about that weird object: https://matheustavares.dev/posts/empty-tree https://matheustavares.dev/posts/empty-tree