When you delve a bit into the internals of git (but haven't got as far as reading the codebase :) ), you come to understand that, when you run git add file.txt
or git add dir/file.txt
, an object is created for the file (a blob is written in git storage), but no objects are created for the directories (e.g: there is no tree object storing the content of the index, hierarchical levels included).
You can create that tree by calling git write-tree
, but this is a separate action.
My question is:
Is there an ulterior motive behind that behavior ?
Are there some specific reasons why running git add
doesn't also create tree objects straight ahead ?
On top of sheer curiosity, I'm also wondering what it would take to have a reflog for the index. If you had a tree, you could store a commit and a floating ref pointing to that tree, much like the stash does.
[update] The other issue I have in mind is: as it is, git add
stores the content of a file in git storage, but not the file name, which is IMHO a bit odd.
git add
or some configuration setting to add this behavior ?