On 3 December 2026, GitHub announced that SHA-256 Git repositories are in public preview on github.com and GitHub Enterprise Cloud with data residency. For the first time, you can create a repository on GitHub that uses SHA-256 instead of SHA-1 to identify every commit, tree and blob.
This guide explains why it matters, what changes in practice, and how to create and test a SHA-256 repository. We ran the local Git commands below with Git 2.47 to confirm the output. The GitHub-specific steps follow the official changelog and the REST API docs.
Why move away from SHA-1?
Git has always used SHA-1 to name objects. Cryptographic attacks, including the 2017 SHAttered collision, exposed weaknesses in SHA-1. Git added SHA-256 repositories in Git 2.30 (December 2020), and GitHub’s changelog notes that they’ll become the default for new repositories in Git 3.0.
Until now, a big obstacle was hosting: you couldn’t push a SHA-256 repository to GitHub. With this preview, that changes for new repositories.
The key rules
From the changelog:
- When you create a repository, you can choose SHA-1 or SHA-256 in the web interface or with the GitHub API.
- When you clone, Git automatically uses the same hash algorithm as the repository on GitHub.
- You can’t change a repository’s hash algorithm after creating it.
- Existing repositories stay on SHA-1.
- Object IDs in SHA-256 repositories are 64 hexadecimal characters long, compared with 40 for SHA-1.
Try SHA-256 locally first
You don’t need GitHub to see what changes. Create a local repository with --object-format:
git init --object-format=sha256 -b main demo
cd demo
git commit --allow-empty -m "init"
git rev-parse --show-object-format # sha256
git rev-parse HEAD | awk '{ print length($0) }' # 64
git log -1 --format='%h %H'
On our machine the last command printed a short hash (7 characters, as usual) and a 64-character full hash. Short hashes in your terminal look the same, but full IDs are longer everywhere: in logs, APIs, webhooks and CI variables.
The repository config records the format:
git config core.repositoryformatversion # 1
git config extensions.objectformat # sha256
You can’t mix formats on push
We tested what happens when you push a SHA-256 repository to a SHA-1 remote. Git refuses:
$ git push ../sha1remote.git main
fatal: the receiving end does not support this repository's hash algorithm
Pushing to a SHA-256 remote worked normally. On GitHub, this means you must create the empty repository as SHA-256 before pushing a local SHA-256 repository to it. You can’t upgrade an existing SHA-1 repository in place. To move a project, you’d create a new SHA-256 repository and migrate the history, which rewrites every object ID.
Create a SHA-256 repository on GitHub
In the web interface, choose the hash algorithm when you create the repository. With the REST API, the create-repository endpoints accept a new hash_algorithm parameter with the values sha1 or sha256. The docs note that sha256 requires Git 2.30 or newer, can’t be changed later, and is in preview and subject to change.
Using the GitHub CLI’s gh api command:
# Personal repository
gh api -X POST /user/repos \
-f name=sha256-demo \
-f hash_algorithm=sha256 \
-F private=true
# Organisation repository
gh api -X POST /orgs/YOUR-ORG/repos \
-f name=sha256-demo \
-f hash_algorithm=sha256
Then push your local SHA-256 repository:
git remote add origin [email protected]:YOUR-USER/sha256-demo.git
git push -u origin main
Check a repository’s hash algorithm
There’s a new endpoint, GET /repos/{owner}/{repo}/hash-algorithm, which returns {"hash_algorithm": "sha1"} or {"hash_algorithm": "sha256"}:
gh api /repos/YOUR-USER/sha256-demo/hash-algorithm --jq .hash_algorithm
# sha256
Locally, git rev-parse --show-object-format gives the same answer for a clone.
What can break: a checklist
GitHub’s own advice is to check your environment before creating SHA-256 repositories. In practice, look at:
- Git versions everywhere. Developer machines, CI runners, build containers and deploy servers all need Git 2.30 or later.
- Other Git implementations. Libraries such as libgit2, and anything built on them (some IDEs, GUIs and language bindings), must support SHA-256 repositories. Test the tools your team actually uses.
- Code that assumes 40 characters. Search for regexes like
[0-9a-f]{40}, database columns sizedCHAR(40)orVARCHAR(40), and validation rules on commit IDs. Update them to accept both lengths. - Webhook and API consumers. Deploy tools, chatops bots and audit scripts that read commit SHAs from GitHub payloads must handle 64-character IDs.
- Hard-coded hashes. Scripts that pin a commit by full hash will need new values in a migrated repository, because every ID changes.
A quick way to find risky patterns in your own code:
git grep -nE "\{40\}|CHAR\(40\)|VARCHAR\(40\)|length.*40"
If your environment isn’t ready, GitHub says you can simply keep creating SHA-1 repositories.
Should you use it now?
- New internal or experimental projects are good candidates. You get the stronger hash from day one and find tooling gaps early.
- Security-sensitive projects, such as signing infrastructure or supply-chain tooling, may value the stronger algorithm most, but test all integrations carefully.
- Large existing projects should wait. Migration rewrites history and every link to a commit, and the feature is still a preview.
Whatever you decide, start making your tools hash-length agnostic now. Git 3.0 is set to make SHA-256 the default for new repositories, so code that assumes 40-character IDs will eventually break.
Takeaway
GitHub’s SHA-256 preview removes the last big hosting barrier to Git’s stronger hash format. Try it on a new repository, check that your Git clients, libraries and webhook consumers handle 64-character object IDs, and share feedback in the SHA-256 repositories community discussion. The full announcement is in the GitHub Changelog.
