Hash (SHA-1)
一句话解释
hash 是唯一 40-character SHA-1 checksum 那个 identifies 提交, 树, or blob in Git.
用大白话说
每个 Git 对象 (提交, 树, blob) 是 identified 通过 SHA-1 hash — 40-character hexadecimal 字符串如 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 " 相同."
示例
# Full hash in log
git log
# commit a1b2c3d4e5f6789012345678901234567890abcd
# Use abbreviated hash
git show a1b2c3d
# Get just the hash of HEAD
git rev-parse HEADHashes 唯一地 identify 提交. Abbreviated hashes 工作 in commands.
相关术语
相关资源
相关课程
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。