Grokking OpenStack

OpenStack - little pieces

The Structure and Habits of Git

Git Init

I learned upon inspection that the following files contained either text or scripts supportive of git but not directly required for this exercise so I deleted them to streamline the visuals.

I removed:

This left me with the following directory structure:

Creating a file does not change the git directory. Adding a file does.

Git Add

So after the first file is staged, the file .git/index is created. Also the directory .git/objects/44 is created and has a file named with a hash. But there is no log yet.

Git Commit

The file COMMITEDIT_MSG is created, containing the first edit message. Two more objects are created, each with a directory and file.

The logs directory is created with the file HEAD containing the information for the commit: the parent, the current id,, creation time and the status. The logs directory also has the path refs/heads leading to file master, which contains the same information as .git/logs/HEAD There is also a new file, master, in .git/refs/heads the content of which is the hash pointing to the initial commit. So right now, of the files I can read, what is pointing to the commit?
The file .git/index might be pointing to the initial commit as well, I don’t know because I can’t read it.

Git Checkout -b Topic

No new objects are created when a new branch is created. Two new files are created, one under .git/refs/heads/name_of_branch, in this case, feature, and one under .git/logs/refs/heads/name_of_branch.

Both files contain the hash of the initial commit, the file under the logs directory also contains the hash of the the parent commit, id of the current commit, of the branch creator as well as the time of creation for the branch, and the type of action it is, in this case: branch: Created from HEAD.

Git Add

The only thing that is created when a file is added to staging is an object, with its directory and file.

Git Commit

So two new objects were created, they each have a directory and a file.

The git log command shows me the log for the branch I am in, in this case the topic branch named ‘feature’.

Git Checkout Master

Git Add

Git Commit

I now have 9 objects.

The git log command shows me the log for the branch I am in at the time of running the command.

Git Merge

Make sure you know where you are with git status prior to merging!

Two objects got created, and a new file called .git/ORIG_HEAD.

After the merge, executing git log from the master branch shows all my commits made in both the master branch and the merged topic branch named feature in the chronological order in which they were created.

I hope you get something useful from this post.

Thank you for supporting this GNOME OPW intern,
Anita Kuno.