Let’s update the README.md file to include an additional exclamation mark, and then explore how Git processes this change.
This repository was made manually without git init!!
Lets make the commit in the usual way and lets observe what git does here. Use git add README.MD
and git commit -m "Update readme"
and then run command tree .git
to check the structure. Can you identify the new objects and see what has changed here?
By adding a single “!” to README.md, git creates three new objects: a blob, a commit, and a tree object. This demonstrates Git’s efficient change tracking, where each content modification generates a unique hash, serving as a checksum to quickly identify changes. Something else very interesting, Git retains old objects, enabling swift version transitions without recalculations, as all blobs and trees are compressed and stored.
Consider a scenario where another file remains unchanged while you modify only one file in the repository. How do you think the structure of your .git directory will adapt to this change? Will Git create new blobs and trees even if only a single file has been updated?