跳到主内容
@wquguru
精选85GitHub Changelog云与平台

GitHub 公开预览支持 SHA-256 Git 仓库

SHA-256 Git repositories are now in public preview

原文
发到 X
推荐理由

核心代码托管平台引入破坏性变更:SHA-256 对象 ID 长度从 40 变为 64 位,所有解析 Object IDs 的工具链、CI/CD 脚本及自动化系统必须适配,否则将直接报错。请检查环境并升级 Git 至 2.30+。

Support for Git repositories that use SHA-256 is now available in public preview on github.com and GitHub Enterprise Cloud with data residency, giving you a more secure alternative to SHA-1 for new repositories.

现在,github.com 和 GitHub Enterprise Cloud(支持数据驻留)已提供对使用 SHA-256 的 Git 仓库的公共预览支持,为新建仓库提供了比 SHA-1 更安全的替代方案。

Git has traditionally used the SHA-1 hash algorithm to identify objects. Cryptographic advances and attacks, including the SHAttered attack, have exposed weaknesses in SHA-1, so Git introduced SHA-256 repositories to improve security. They've been available since Git 2.30, which shipped in December 2020, and they'll become the default for new repositories in Git 3.0.

Git 传统上使用 SHA-1 哈希算法来标识对象。随着密码学进展和攻击手段的出现(包括 SHAttered 攻击),SHA-1 的弱点暴露无遗,因此 Git 引入了 SHA-256 仓库以提升安全性。自 2020 年 12 月发布的 Git 2.30 版本起,SHA-256 仓库功能就已可用,并将在 Git 3.0 中成为新建仓库的默认选项。

Choose a hash algorithm for new repositories

为新仓库选择哈希算法

When you create a repository, you can now choose either SHA-1 or SHA-256 as its hash algorithm in the web interface or with the GitHub API. When you clone a repository, Git automatically uses the same hash algorithm as the repository on GitHub, so you don't need to check it beforehand.

创建仓库时,您现在可以在 Web 界面或通过 GitHub API 选择 SHA-1 或 SHA-256 作为其哈希算法。克隆仓库时,Git 会自动使用该仓库在 GitHub 上相同的哈希算法,因此您无需事先检查。

Note: You can't change a repository's hash algorithm after you create it. Existing repositories on GitHub continue to use SHA-1.

注意:创建仓库后无法更改其哈希算法。GitHub 上的现有仓库继续使用 SHA-1。

Compatibility considerations

兼容性注意事项

Object IDs in SHA-256 repositories are 64 hexadecimal characters long, compared with 40 in SHA-1 repositories. Before you create a SHA-256 repository, make sure your environment is ready:

SHA-256 仓库中的对象 ID 长度为 64 个十六进制字符,而 SHA-1 仓库为 40 个字符。在创建 SHA-256 仓库之前,请确保您的环境已准备就绪:

  • Use Git 2.30 or later, and confirm that any other Git implementations you use, such as libgit2, support SHA-256 repositories.
  • Update any tooling that reads object IDs from API responses, webhooks, or other sources so it handles both 40- and 64-character IDs.
  • Check which hash algorithm a repository uses by calling the REST API endpoint to get the hash algorithm for a repository.
  • 使用 Git 2.30 或更高版本,并确认您使用的其他 Git 实现(如 libgit2)支持 SHA-256 仓库。
  • 更新任何从 API 响应、Webhook 或其他来源读取对象 ID 的工具,使其能够同时处理 40 位和 64 位的 ID。
  • 通过调用 REST API 端点获取仓库的哈希算法,以检查仓库使用的是哪种哈希算法。

If your environment isn't ready for SHA-256, you can keep creating SHA-1 repositories.

如果您的环境尚未准备好支持 SHA-256,您可以继续创建 SHA-1 仓库。

Try creating a SHA-256 repository, then share your feedback or report issues in the SHA-256 repositories community discussion.

尝试创建一个 SHA-256 仓库,然后在 SHA-256 仓库社区讨论中分享您的反馈或报告问题。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件