Interview Prep/Git & GitHub/Git internals: objects, refs and the index

Explain how a tree object is encoded and why renames are not stored.

AdvancedConceptGit internals: objects, refs and the index
Answer

A tree is a list of entries <mode> <name>\0<20-byte-binary-id> sorted by name. Modes include 100644 (file), 100755 (executable), 120000 (symlink), 040000 (tree) and 160000 (gitlink, a submodule). Git records no rename metadata; git log --follow, diff -M and blame -C detect renames heuristically by comparing blob similarity (default threshold 50%).

git ls-tree -r HEAD
git diff -M --stat HEAD~1
All Git & GitHub questions Roadmap: Git & GitHub

More on Git internals: objects, refs and the index