My current project at Disqus involves writing code that operates on Git repositories without the usual comfort of CLI programs. Since I have never touched the internals of a Git repository before, I felt like this was a good chance to brush up my knowledge of Git. So I got two books—Pro Git by Scott Chacon and Version Control with Git by Jon Loeliger. I didn’t have any particular criteria when I picked up these books—I just needed some literature that would explain Git’s philosophy, common operations and, more importantly, its architecture.
Pro Git starts with explaining the basic philosophy behind Git—like the notion of using snapshots instead of the diffs used in classic version control systems, or its integrity control using
add -i and
add -p. The last chapter presents a walkthrough on how Git stores objects internally. And, while it was definitely helpful, it wasn’t enough—I failed at my attempt to manually create, initialize and branch a repository using libgit2.
Version Control with Git is almost identical to Pro Git in terms of content—it covers all the same topics such as basic commands and tools, branching, remote repositories, different workflows. Since I read it after Pro Git, I basically skimmed it to see if there was anything new.
It is worth noting that both books are available both on paper and electronically. In addition to that, Pro Git has a free online copy available at progit.org.
I found that both books are pretty well written and do a good job explaining how to use Git and—more importantly—how to build your daily workflow around distributed version control systems. I want to especially stress that part because I have seen many people using Git in the same way they used Subversion and, while it is perfectly acceptable, Git is simply much more than that.
Which one would I recommend for somebody who is new to Git and distributed version control? Pro Git. I liked the flow better and you can always check it out online before purchasing a copy.
Now, unfortunately, neither of the books turned out to be what I was looking for. I was lacking the fundamental understanding of Git—why does it store objects the way it does, what are branches, how does
git-reset work, etc — and I didn’t find that information in those books. I continued looking for another resource.
The solution came in the shape of a great paper titled Git from the bottom up. It starts with explaining how Git—fundamentally a key-value store—is architected and then explains how familiar things like commits, branches and tags are built on this architecture. After reading this paper, I finally understood how commits and branches in Git are different from their counterparts in Subversion, how
git-reset works and other topics that are not usually covered in literature or blogs on Git.
I would definitely recommend Git from the bottom up to anyone looking for solid understanding on Git’s architecture and internals.
Do you have your best resource on Git? Do you know how to be more productive with Git? If you do, please share them in comments below.
Thanks to Pamela Fox for editing drafts of this.