A memorizable description of git commands.

If you ever worked with a version-control system, you will probably get nervous about any file not under the shelter of the perpetual possibility to undo changes. I have been using git for quite some time now, mostly for my solitary work (dissertation, papers, some code). Since it is decentralized, it is easy to backup, and I am quite happy with it.

One feature of git, however, I carefully avoided is branching. Of course, I tried it once when I read the git manual, and I can work with existing branches, but I always felt a bit insecure of what the commands I typed were really doing.

I have some hope that this will change now. There is a nice post titled Git for computer scientists that explains concisely and (for me) memorizably how git branches work: namely, in terms of the underlying data structures. I can only recommend investing 15 calm minutes in reading the article.

Unfortunately, the article stops short when it comes to the meaning of git’s various commands. I’m missing a concise specification in terms of git’s data structures, so I’ll start my own here. (I do not attempt to make it comprehensive, but rather memorizably concise).

  • git branch <name>
    Create a new named ref pointing at the commit currently checked out in working area.

A thorough understanding of (an abstract view of) the inner workings makes me feel comfortable to make more use of one of git’s most celebrated features.