Git object database và commit graph
Git lưu immutable content-addressed objects; branches/tags/HEAD chỉ là refs trỏ graph.
Objects
Blob chứa file content, tree ánh xạ names/modes đến blobs/trees, commit trỏ root tree + parent(s) + metadata/message, annotated tag trỏ object và metadata/signature. Object ID hash type/size/content, không “hash file name”.
Working tree, index, repository
Working tree là files checkout; index/staging là proposed next tree; repository giữ objects/refs. git add cập nhật index, commit tạo tree/commit rồi move current branch ref. Reset modes thay refs/index/working tree theo scope khác nhau.
Refs and reachability
Branch là movable ref; HEAD symbolic ref hoặc detached. Remote-tracking refs là local records. Reflog ghi ref movements cục bộ và hỗ trợ recovery trước expiry/gc. Unreachable objects có thể bị prune.
Storage
Loose objects được pack; packfiles dùng delta compression. Git graph distributed: clone có history/refs theo fetch; merge base quyết định three-way merge. Commit identity đổi khi parent/tree/message/metadata đổi, nên rebase/cherry-pick tạo commits mới.