git-cat-file失败,没有其他信息

时间:2014-05-18 04:07:28

标签: git

git cat-file -p master^{tree}

虽然这直接来自pro git book,pg 226,但它并不适合我。我只是返回命令帮助文本,没有其他错误或文本:

D:\Users\jon\Documents\GitHub\FilePathContextMenu [master]> git cat-file -p mast
er^{tree}
usage: git cat-file (-t|-s|-e|-p|<type>|--textconv) <object>
   or: git cat-file (--batch|--batch-check) < <list_of_objects>

<type> can be one of: blob, tree, commit, tag
    -t                    show object type
    -s                    show object size
    -e                    exit with zero when there's no error
    -p                    pretty-print object's content
    --textconv            for blob objects, run textconv on object's content
    --batch[=<format>]    show info and content of objects fed from the standard
 input
    --batch-check[=<format>]
                          show info about objects fed from the standard input

1 个答案:

答案 0 :(得分:2)

请注意,如果您在cmd prompt中使用该行(使用Git For Windows,因为您似乎在Windows上,根据your previous question判断),您将获得:

fatal: Not a valid object name master{tree}

你需要逃离^,它在cmd shell中是&#39; ^^&#39;:

C:\Users\vonc\prog\git\git>git cat-file -p master^^{tree}
100644 blob 5e98806c6cc246acef5f539ae191710a0c06ad3f    .gitattributes
100644 blob dc600f9b36d09f0668064e044520c7ce633f09d8    .gitignore
100644 blob 11057cbcdf4c9f814189bdbf0a17980825da194c    .mailmap
100644 blob 536e55524db72bd2acf175208aef4f3dfc148d42    COPYING
040000 tree 81319ed97d893e6e4afd37697ceac6be04e1a02b    Documentation
100755 blob 2b97352dd3b113b46bbd53248315ab91f0a9356b    GIT-VERSION-GEN

注意:git cat-file -p master^{TREE}不能工作:树必须是小写的。