How Git works?#

Git basically has 3 components.

  • Commit
  • Tree
  • Blob

Whenever u do any change in your repo/folder, first u do git add, then the git will compress ur entire file into a blob(kinda binary file) and then generates a sha256 hash as the file name for that blob and store under .git/objects/.

Once u do git commit -m ‘msg’, git will create two hash files `Commit` and `Tree`, `Tree` hash file will contain the entire file details at that particular point in time of the commit(this also compressed and stored), also this points to the blob hash file. `Commit` this hash file will contain the commiter author details and parent commit hash if so and Tree hash.