A Random Walk Through Git

submited by
Style Pass
2021-06-07 12:30:04

This tutorial is an in-depth look at how Git works, performing a lot of sometimes unusual steps to walk through interesting details. You will have to pay attention closely, or you will get lost on the way. But do not despair; you can run this tutorial on your computer, at the speed you want, skip to any step you want, and investigate the state of things in another terminal window at all times. In fact, you are looking at an HTML file generated from the output of that tutorial. (that's why there is that "echo Hi" thing above: the hack that the tutorial script is only allows comments after commands. :) ) The code of the tutorial is here: github.com/bakkenbaeck/a-random-walk-through-git - clone it and run it on your machine! This tutorial is NOT for absolute beginners, nor is it a collection of "cooking recipies". Recipies will not help you understanding the broad picture, nor will they get you out of tricky situations. Some deeper understanding by experimentation and investigation will, though. So let's get started.

First, a quick recap of Git-related terms. tree: set of files (filenames, perms, pointers to subtrees/file blobs, NOT timedates) commit: metadata (time, author, pointer to tree, possibly pointer to parent commit(s)) HEAD: last commit hash/parent of next commit (local only, modified by, e.g., git checkout) index/staging/cache: HEAD plus "changes to be committed" (local only, modified by, e.g., git add/reset, stored in .git) working directory/WIP: index plus "changes not added for commit" (plain files, local only, modified by, e.g., git checkout/reset --hard) Ok? Then let's init a Git repository... and have a look at the files in the .git/ folder.

Leave a Comment