git计算文件哈希如何? [英] How does git compute file hashes?

查看:237
本文介绍了git计算文件哈希如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储在树对象中的SHA1哈希(由 git ls-tree 返回)与文件内容的SHA1哈希值不匹配(由<$ c返回
$ b

The SHA1 hashes stored in the tree objects (as returned by git ls-tree) do not match the SHA1 hashes of the file content (as returned by sha1sum)

$ git cat-file blob 4716ca912495c805b94a88ef6dc3fb4aff46bf3c | sha1sum
de20247992af0f949ae8df4fa9a37e4a03d7063e  -

git计算文件散列如何?它在计算哈希之前是否压缩内容?

How does git compute file hashes? Does it compress the content before computing the hash?

推荐答案


Git用blob ,然后是长度(作为
人类可读的整数),后面跟着一个NUL字符

$ echo -e'blob 14 \0你好,世界!'| shasum
8ab686eafeb1f44702738c8b0f24f2567c36da6d

来源: http://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html

这篇关于git计算文件哈希如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆