Skip to content

GitHub Goes SHA-256

Published:

When I was creating a new repo on GitHub, I noticed a new option asking me to pick a hash algorithm: SHA-1 or SHA-256. I picked SHA-256, then went to find out what I had just signed up for.

What the option is

Git names every object (commits, trees, blobs, tags) by the hash of its contents. That hash is the commit ID you copy around. Since Git’s start, the hash has been SHA-1.

GitHub put SHA-256 repositories into public preview on December 3, 2026. You choose the algorithm when you create a repo, in the web UI or through the API.

You can’t change it afterwards. Existing repos stay on SHA-1.

SHA-1 vs SHA-256

SHA-1 SHA-256
Output size 160 bits 256 bits
Commit ID length 40 hex characters 64 hex characters
Collision resistance Broken in practice (SHAttered, 2017) No known practical attack
Git default Yes, today Planned default for new repos in Git 3.0

A collision means two different inputs with the same hash. If someone can make two different objects share an ID, they could swap one for the other, and the ID would no longer prove what you’re looking at.

Git has been running a hardened SHA-1 that detects the known collision attack since 2017, so SHA-1 repos aren’t wide open today. SHA-256 removes the dependency on a broken function instead of patching around it. Git has supported it since 2.29 (2020), and GitHub recommends 2.30 or later.

What changes for you

Longer IDs. A SHA-256 commit ID is 64 characters instead of 40. Short IDs like a1b2c3d still work in day-to-day commands.

Your Git version matters. GitHub recommends Git 2.30 or later. Check yours with:

git --version

Tools that parse IDs. Anything that reads commit SHAs from the API, webhooks or CI and assumes 40 characters (a regex like [0-9a-f]{40}, a fixed-width DB column) needs to accept 64. Libraries such as libgit2 also need SHA-256 support.

Cloning just works. Git reads the repo’s format on clone and uses the right hash.

Check which one a repo uses

Inside any clone:

git rev-parse --show-object-format

It prints sha1 or sha256.

Try it locally

You don’t need GitHub to see the difference:

git init --object-format=sha256 demo
cd demo
git commit --allow-empty -m "first"
git log -1 --format=%H

The last command prints a 64-character commit ID.

Should you pick SHA-256?

For a new repo with a modern Git and no older tooling to worry about, yes. It’s where Git is heading. If your CI, deploy scripts or integrations assume 40-character SHAs, stay on SHA-1 for now, since there’s no switching later.

Agent vs Agent: The Two-Week Attack on Perplexity