How to compute the git hash-object of a directory?

前端 未结 7 1121
既然无缘
既然无缘 2020-12-09 16:28

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**

*:         


        
7条回答
  •  旧巷少年郎
    2020-12-09 17:05

    I'm not sure about getting the hash for a directory outside of a git repository, but for a directory inside of a repository, try this to print only the hash:

    git rev-parse HEAD:some/directory
    

    There is no need to use other commands that require additional processing.

    This will also work but provides additional information you may not want (such as the file mode and other data):

    git ls-tree HEAD some/directory
    

提交回复
热议问题