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.
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.
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.
Note: You can't change a repository's hash algorithm after you create it. Existing repositories on GitHub continue to use 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:
- 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.
If your environment isn't ready for SHA-256, you can keep creating SHA-1 repositories.
Try creating a SHA-256 repository, then share your feedback or report issues in the SHA-256 repositories community discussion.