Git

Git has an objects folder. It has got loads and loads of files. The name of the file is the hash. When we start with the first commit, all the files get added to this big folder. They are broken into subfolders but we don’t need to think of that. That is based on first part of the hash or something. But they are not organized or ordered by any way. Think of it as key-value thing with the hash of the file’s contents. File’s contents. That is important. If two files have the same content, there is only one item in this object store. As we add more and more commits, we keep adding more and more files. We add the full file only, not the changes. So, if we have a 10 MB file and modify a tiny part of it, new file is added to this store. Then commit referes to these files. These objects, as they are called. There is a way to compress these objects. A commit is a tree. No, a commit has a tree among other things. So each end node in the tree has a hash. We can get the file for the has from the objects folder. The commits form a graph too. Directed acyclic graph, if I am not much mistaken. Every end node is a hash. Every folder has a hash, based on the files underneath. The root of the file also has a hash. The commit with all other metadata also has a cache. What are these other metadata? Commit messaga, time, usename and email. Is parent commit included in this metadata? Not sure. We have this thing called head. That is what we compare the current working state againt. We can compare head with anything. When we checkout a branch, head changes. When we add a new commit head changes. Head is a hash or it is a branch name? Branch name resolves to a hash only. That is all that needs to be stored. To list the branch as we see them, the git program traverses the commits one by one. Pulling from a remote, gets all the objects and the commit data. Commit data has no awareness of the remote. The remote branch gets a branchname that’s all. Pushing also pushes the commits to the specified remtoe branch. It can be done if it is a fastforward. Otherwise it fails.