Git 和 SHA-256
Git and SHA-256
git (2.30.0) 的当前版本是否已经默认使用 SHA256 来计算提交哈希值?
如果不是,如何为新的 git 存储库启用 SHA-256 以及如何检查某个 git 存储库是否使用 SHA-256 或 SHA-1 作为其提交哈希?
根据版本 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.
使用 SHA-1 还是 SHA-256 是 Git 最新版本中的每个存储库设置。该计划最终使将数据存储在 SHA-256 存储库中并使用 SHA-1 名称或 SHA-256 名称访问对象成为可能。 SHA-1 保持默认。
请注意,SHA-256 模式是实验性的,理论上可以更改,但没有这样做的计划。 Git 开发人员正在尽一切努力不破坏与现有 SHA-256 存储库的兼容性。
要使用 SHA-256 创建新的存储库,请使用 --object-format
选项到 git init
。如果您想知道 local 存储库使用哪种算法,运行 git rev-parse --show-object-format
将输出 sha1
或 sha256
。要查看 远程 存储库的哈希值,您可以使用 git ls-remote
并验证打印的哈希值的长度。
请注意,没有主要的锻造厂支持 SHA-256,因此无法将此类存储库上传到它们。
git (2.30.0) 的当前版本是否已经默认使用 SHA256 来计算提交哈希值? 如果不是,如何为新的 git 存储库启用 SHA-256 以及如何检查某个 git 存储库是否使用 SHA-256 或 SHA-1 作为其提交哈希?
根据版本 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.
使用 SHA-1 还是 SHA-256 是 Git 最新版本中的每个存储库设置。该计划最终使将数据存储在 SHA-256 存储库中并使用 SHA-1 名称或 SHA-256 名称访问对象成为可能。 SHA-1 保持默认。
请注意,SHA-256 模式是实验性的,理论上可以更改,但没有这样做的计划。 Git 开发人员正在尽一切努力不破坏与现有 SHA-256 存储库的兼容性。
要使用 SHA-256 创建新的存储库,请使用 --object-format
选项到 git init
。如果您想知道 local 存储库使用哪种算法,运行 git rev-parse --show-object-format
将输出 sha1
或 sha256
。要查看 远程 存储库的哈希值,您可以使用 git ls-remote
并验证打印的哈希值的长度。
请注意,没有主要的锻造厂支持 SHA-256,因此无法将此类存储库上传到它们。