如何计算目录的git散列对象? [英] How to compute the git hash-object of a directory?
问题描述
有没有人有一个在目录上使用git hash-object的例子?它很容易在一个文件*上运行,但不能像我期望的那样工作。**
*:git hash-object c:\somefile.txt
**:git hash-object -t树c:\somedirectory
当我尝试在目录中使用散列对象时,它抱怨致命的:无法打开'C:\someDirectory':Permission denied
git hash-object -t树
预计文件参数是描述树中条目的文件,而不是文件系统中的目录。我从此处注释了解此命令是期望以二进制格式描述树的文件,并且使用 git mktree
可以更容易地创建树对象。
git mktree
理解你输入的格式(例如) git ls-tree HEAD
。有一个很好的例子,在 git hash-object 和 git mktree
=http://git-scm.com/book/en/v2/Git-Internals-Git-Objects =nofollow noreferrer> Git Community Book 。
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 tree
is 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 use git mktree
for you to create the tree object.
git mktree
understands input of the format you get from (for example) git ls-tree HEAD
. There is a nice example of constructing a tree from scratch using git hash-object
and git mktree
in the Git Community Book.
这篇关于如何计算目录的git散列对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!