How GIT works under the HOOD?

git objects

3 basic objects in git:

  • commit
  • tree
  • blob (branch 都不是 object, branch 只是个指向于某个 commit 的 pointer)

一个 commit 的 data structure:

  • commit = tree + metadata

tree:

  • a tree is some blobs and trees
  • basically like a dir, there could be just files or files and dirs inside
  • blob:
  • a blob is a file
  • basically like a file
  • the whole file that changed between this commit and parent commit (not just the diff)
  • files that didn’t change will NOT be in the blob

tags:

  • 实际上可以理解为一个指向某个特定 commit 的 pointer; 像是个 branch, but never moves
  • gives a friendlier name than a commit