在内部,Git 是一个内容寻址对象存储——它将所有内容都存储为对象(blobs、trees、commits、tags),通过它们的 SHA-1 哈希来标识。理解这个模型能够揭开 Git 的神秘面纱,并解释为什么它的操作表现得如此。
Git 是一个内容寻址对象存储
Git stores 4 types of OBJECTS, each identified by the SHA-1 HASH of its content:
BLOB → file CONTENTS (just the data, no filename)
TREE → a directory: maps names → blobs (files) and trees (subdirs) + permissions
COMMIT → a snapshot: points to a TREE (the root) + parent commit(s) + author/message
TAG → an annotated tag object (points to a commit, with metadata)
→ Content-addressable: an object's ID IS the hash of its content (same content = same hash).
