当前版本的git (2.30.0)默认情况下是否已经使用SHA256计算提交散列?如果不是,如何为新的git存储库启用SHA-256,以及如何检查某个git存储库是使用SHA-256还是SHA-1作为提交散列?
发布于 2021-01-24 18:48:48
在Git的最新版本中,是使用SHA-1还是SHA-256是每个存储库的设置。最终的计划是能够将数据存储在SHA-256中的存储库中,并使用SHA-1名称或SHA-256名称访问对象。沙一仍然是默认的。
请注意,SHA-256模式是实验性的,理论上可以改变,但没有计划这样做。Git开发人员正在尽一切努力不破坏与现有SHA-256存储库的兼容性。
若要使用SHA-256创建新的存储库,请使用--object-format选项对git init进行操作。如果您想知道本地存储库使用哪种算法,请运行git rev-parse --show-object-format,它将输出sha1或sha256。要查看远程存储库的散列,可以使用git ls-remote并验证所打印的散列的长度。
请注意,没有主要的伪造支持SHA-256,因此这类存储库不能上传到它们。
发布于 2021-01-24 13:41:28
根据2.30.0版的man page for git-init,sha-256支持仍然被认为是实验性的:
--object-format=<format
Specify the given object format (hash algorithm) for the
repository. The valid values are sha1 and (if enabled) sha256.
sha1 is the default.
THIS OPTION IS EXPERIMENTAL! SHA-256 support is experimental and
still in an early stage. A SHA-256 repository will in general not
be able to share work with "regular" SHA-1 repositories. It should
be assumed that, e.g., Git internal file formats in relation to
SHA-256 repositories may change in backwards-incompatible ways.
Only use --object-format=sha256 for testing purposes.https://stackoverflow.com/questions/65870508
复制相似问题