Skip to content

Hash (SHA-1)

In one line

A hash is a unique 40-character SHA-1 checksum that identifies a commit, tree, or blob in Git.

In simple words

Every Git object (commit, tree, blob) is identified by a SHA-1 hash — a 40-character hexadecimal string like a1b2c3d4e5f6.... This hash is computed from the object's content, making it a content-addressable identifier.

Commit hashes are how Git references specific commits. You see them in git log output. You can use abbreviated hashes (first 7-8 characters) in most commands, and Git will resolve them to the full hash.

Hashes are immutable — if the content changes, the hash changes. This is how Git detects corruption and ensures integrity. It also means that operations like rebase and amend create new commits with new hashes, even if the changes are "the same."

Example

bash
# Full hash in log
git log
# commit a1b2c3d4e5f6789012345678901234567890abcd

# Use abbreviated hash
git show a1b2c3d

# Get just the hash of HEAD
git rev-parse HEAD

Hashes uniquely identify commits. Abbreviated hashes work in commands.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary