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

Walk through what `git commit` does at the object level.

IntermediateConceptGit internals: objects, refs and the index
Answer

Git writes the index as tree objects (one per directory, bottom up), creates a commit object referencing the root tree, the current HEAD commit as parent, plus author/committer and message, then updates the branch ref that HEAD points to. Finally the reflog entries for the branch and HEAD are appended.

git cat-file -p HEAD
# tree <id>
# parent <id>
# author ... committer ...
All Git & GitHub questions Roadmap: Git & GitHub

More on Git internals: objects, refs and the index