Does anyone have an example of using git hash-object on a directory? It works easily enough on a file* but doesn’t work as I’d expect for a directory**
*: git hash-object c:\somefile.txt
**: git hash-object -t tree c:\somedirectory
When I try to use hash-object with the directory, it complains “fatal: Cannot open ‘C:\someDirectory’: Permission denied”
git hash-object -t treeis expecting the file parameter to be a file that describes the entries in the tree, rather than a directory in the filesystem. I understand from the comment here that this command is expecting a file that describes the tree in a binary format, and that it would be easier to usegit mktreefor you to create the tree object.git mktreeunderstands input of the format you get from (for example)git ls-tree HEAD. There is a nice example of constructing a tree from scratch usinggit hash-objectandgit mktreein the Git Community Book.