git计算文件哈希如何?

编程入门 行业动态 更新时间:2024-10-24 13:25:42
本文介绍了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

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

更多推荐

git计算文件哈希如何?

本文发布于:2023-11-03 12:33:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555145.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!