This blog post is about a book titled “Learning Git” written by Anna Skoulikari

The author of the book, Anna Skoulikari, says that she began writing this book to understand git better. When she made a transition in to a web development role, she joined a bootcamp where git was introduced in a few days and all she could ever remember after the bootcamp were the commands, git add, git commit and git push. She had no mental model of git that could help her work with git In an online interview, she says that her desire to understand git lead her to pursuing many online resources. It turned out that most of them were not suitable to people like her who were transitioning in to git without any programming background. In order to fill that perceived gap, she created an online course that eventually lead her to writing this book. One thing I loved about the way she went about writing the book is the mindset - she started off the book as a prototype, released it to a set of readers, took their feedback and iterated the prototype multiple times before she could make the book in to a final product. She refers to the book as an app that iterated multiple times to get to where it is today, Love the way she approached book making from that perspective of release early, release often mindset of an app developer.

git is something a diverse set of personas need to be comfortable with, not just the programmers. For example a blogger like me, I use git to push all the blog posts to github account that then syncs with blog hosting provider’s infra. Without knowing git it would be difficult to put in place a CI/CD workflow for blogging.

I looked up my blogging archives and found that I had read two books on git. I had read Getting good with git in 2011 and Learn Git in a month of lunches in 2016. I remember working diligently through the latter for about a month to understand the basics of git. For almost a decade since then, I never had a chance to read anything on git. For some reason, I picked up this book recently and read it cover to cover. I have thoroughly enjoyed rereading the basic ideas of git from this book. This book is probably the best book to learn about git for non programmers and stands out from the rest because of the following reasons:

  • There is absolutely no pre-requisites of programming needed to read this book
  • The book has fantastic visuals throughout dozen chapters that will serve as visual cues for various concepts discussed in the book
  • The book introduces “git diagram” - a great mental model for git. Most of the visual images around git that one comes across look like UML diagrams and are useful for the programming community. For a non-programmer, such visuals are of limited use. This book on the other hand has a great way to showcase the main components of git
  • The book’s content is agnostic to OS, the software that you want to use for git. Be it Mac or Windows, you can get started on working through the book. There are no specific text editor, git hosting provider that the author prescribes.
  • There is no code in the book. All the 12 chapters in the book revolved around a single project called “rainbow” that is a collection of two text files. That’s it. All are plain text files in the working directory. This means that you don’t need to know any programming language to work through the book
  • I think the highlight of the book is the simplicity through with most of the git concepts are presented. All the concepts around fast forward merge, three way merge, merge conflicts and rebasing are explained using two text files with a few lines that talk about the colors of the rainbow
  • git by default means one has talk about commit hashes. The author has used colors to represent various commits in the project and by doing so, has created a powerful visual where commit history in a branch can be visualized in a tree diagram of nodes with various colors.
  • Intelligent use of node colors and arrow shapes makes it easy to understand the commit history of git project
  • The book needs to be read in a sequential manner. But the author also creates an appendix where there are instructions to set up git repositories for each chapter so that you can dive in to any of them independently
  • There is not a single screenshot of any software in the book and hence the book will not be out of date because of UI changes
  • Colors of rainbow is something we all know and by focusing on rainbow as a way to represent various commits is THE highlight of the book.

Useful Mental models

Here are visuals from the book that can serve as mental models

Git diagram

Repository

Remote and Local Repository

Regular commits

Merge commits

Rebase commits

Commands mentioned

S.No Git Command Description
1 git config –global –list List the variables in the global Git configuration file
2 git config –global user.name “<name>” Set your name in the global Git configuration file
3 git config –global user.email “<email>” Set your email address in the global Git configuration file
4 git init Initialize a Git repository
5 git init -b <branch_name> Initialize repo and set initial branch name
6 git status Show state of working directory and staging area
7 git add <filename> Add one file to the staging area
8 git add <filename> <filename> … Add multiple files to the staging area
9 git add -A Add all edited/changed files to the staging area
10 git commit -m “<message>” Create a new commit with a message
11 git log Show commits in reverse chronological order
12 git branch List local branches
13 git branch <new_branch_name> Create a branch
14 git switch <branch_name> Switch branches
15 git checkout <branch_name> Switch branches
16 git merge <branch_name> Integrate changes from one branch into another
17 git log –all Show all commits across all branches
18 git checkout <commit_hash> Check out a commit
19 git switch -c <new_branch_name> Create and switch to new branch
20 git checkout -b <new_branch_name> Create and switch to new branch
21 git push Upload data to a remote repository
22 git remote add <shortname> <URL> Add remote repository
23 git remote List remote repository connections
24 git remote -v List remote repositories with URLs
25 git push <shortname> <branch_name> Push branch to remote
26 git branch –all List local and remote-tracking branches
27 git clone <URL> <directory_name> Clone a remote repository
28 git push <shortname> -d <branch_name> Delete a remote branch
29 git branch -d <branch_name> Delete a local branch
30 git branch -vv List local branches and upstream branches
31 git fetch <shortname> Fetch data from a specific remote
32 git fetch Fetch data from origin
33 git fetch -p Prune deleted remote branches and fetch updates
34 git branch -u <shortname>/<branch_name> Set upstream branch for current branch
35 git pull <shortname> <branch_name> Fetch and integrate changes from remote
36 git pull Fetch and integrate using upstream info
37 git merge –abort Abort the merge process
38 git rebase <branch_name> Reapply commits on top of another branch
39 git restore –staged <filename> Restore a file in the staging area
40 git rebase –continue Continue rebase after conflict resolution
41 git rebase –abort Abort the rebase process

Takeaway

This book serves as an inspiration for all those authors who write books on technical topics for broader audience. Display of powerful visuals, use of colors, use of simple project to illustrate the various concepts are the best ingredients of a beginners book an this book has it all. Loved rereading about git from this book and kudos to the author for distilling the key ideas in ways that ANYONE can understand them.