Verdict: Highly recommended
This book should have been called Introducing Git. The author started off attending a bootcamp to learn web development and then got a job working on a website for a big company. She decided to teach herself the ins and outs of Git – and, in the process, created an online Git course and she eventually decided to turn the course into a book – this book.
I, (the reviewer), started off in Version Control in pre-Git days, in a software house that didn’t have a budget for some Version Control System licences, so I spent 2.5 days designing a version control system and 2.5 days writing it. The result was a very basic VCS called SCHOLAR (Source Code Held Offline Archiving/Retrieving) used in-house at LiBRiS Computing Ltd for the life of the company.
The book is intended for “anyone who wants to learn the basics of how Git works” and is “especially designed for individuals that are just getting started learning technical skills”. I feel that this book is the ideal textbook for a Git bootcamp. It can be used for other approaches to learning Git but, if you are starting out in tech and wish to learn Git, you would be wise to find yourself a mentor to advise you on how to cope with any technicalities that arise.
This book will get you to a certain level of competence – but I found that competence to be quite brittle. The book would have been better if, throughout, it had suggested sources for further learning and practise.
The Preface introduces the book. The focus of the book, is on the ‘Rainbow’ project, a Git repository initially with a single text file in it, rainbowcolors.txt. It introduces the concepts of Repositories and Commits. As well as the Rainbow project, there is another example project, ‘The Book Project’, which is a multi-file project referred to throughout the book. It mentions the book’s Repository [1]
Chapter 1, ‘Git and the Command Line’, is a very gentle introduction. It covers technicalities such as opening a command line window, using it to execute commands etc. Throughout the book, the author provides specific instructions for “macOS and Microsoft Windows users”, augmented by the book’s GitHub page. Linux users are assumed to know “some command line basics”. Help is provided for mac, Windows, and Linux in the book’s repository [1]. Linux users are expected to fend for themselves.It then introduces basic Git commands – git version
and the use of git config
to initialise your user.name
and user.email
settings.
For Ubuntu Linux systems (which is Debian Linux based), I did this:
sudo apt update sudo apt upgrade sudo apt install git git-doc gitk git-gui
New git users should be aware of the built-in git help pages available from the command line. Here are a few I’m aware of:
$ git help # names help pages for certain commands.$ git help tutorial #
a tutorial introduction to Git. $ git help core-tutorial # A Git core tutorial for developers. $ git help everyday # Everyday Git With 20 Commands Or So. $ git help git # shows the Git user manual. $ git help glossary # provides a much needed glossary.# bash
commands to get more git info from man pages: $ apropos git- $ apropos '^git[a-z]' # Slightly modified Git alias provided by Jonathan Wakely on accu-general. # This provides you with the command $ git quick-view $ git config --global alias.quick-view "log --pretty='format:%cd %s' --date=format:'%F %T'"
The Git user manual, as supplied by the git-doc package on Ubuntu Linux systems can be found locally at /usr/share/doc/git/html/user-manual.html
Chapter 2, ‘Local Repositories’, introduces the concepts of both local and remote repositories. The command git init
is used to turn a directory called rainbow into a local repository. For the remainder of this review, I will use the shorter term ‘repo’ rather than ‘repository’. Due to certain sensitivities, rather than calling the key branch of the repo ‘master’ (as is the default), this book prefers the term ‘main’ instead. This is accomplished by passing more parameters to git init
. It does encourage the reader to monitor the contents of the ~/Desktop/rainbow/.git directories. Whilst that is helpful, I have been encouraged to “interrogate the repo, not the filesystem”. The ‘staging area’, aka index, aka cache, is introduced. As is the notion of commits and commit histories.
Chapter 3, ‘Making a commit’, is where the reader is guided through some fundamental commands – git status
to find out the state of the working tree (working directory according to this book), git add
to put things into the staging area, and finally git commit
to actually put rainbowcolors.txt into the local git repo. The git log
command is used to show the history of commits.
Chapter 4, ‘Branches’, shows how to use a branch in addition to the current main branch. In particular, the visual diagram of the Project directory, working directory, and local repository are very helpful in indicating the state of the Rainbow repo. There is more use of the git status
command. The gitk
command provides a GUI for looking at repo but it is not dealt with which is a pity because it can be very useful. I didn’t use the ‘git gui’ because I was focussed on using the command line but, again, mentioning that would have been useful.
Chapter 5, ‘Merging’, introduces the two types of merges: fast-forward and three-way. Using the rainbow project, it shows the reader how to perform a merge – and, because the development histories have not diverged, it is a fast-forward merge.
Chapter 6, ‘Hosting Services and Authentication’, was a stumbling block for me. This is the second half of the book, that includes the use of hosting services and remote repositories. The author states that this subject is prone to change so she recommends that the reader refers to [1] as well as this chapter. That sent me down the path of trying to use HTTPS to authenticate. That was a dead end for me. I asked for help on accu-general [2] and was advised to use SSH. I used Wikipedia as well as the book SSH Mastery [3]. Somehow I managed to get going with SSH.
Chapter 7 is all about ‘Creating and Pushing to a Remote Repository’. There are many diagrams which helps the reader keep track of what is going on – and various commands are explained as well (git init
, git clone
, git remote
and git push
, to name a few that are used). At the end of this chapter, the reader will have two repositories – rainbow (local repo) and rainbow-remote (remote repo stored on GitHub).
Chapter 8, ‘Cloning and Fetching’, emulates what it is like to work with a friend on a remote repository – an additional local repo, friend-rainbow, is created using git clone
and rainbowcolors.txt is edited in that new repo. Then friend-rainbow has the redundant branch ‘feature’ removed and the author explains how to propagate the changes – initially to the remote repo, next to the other local repo, ‘rainbow’. This is a solid chapter. I did notice, however, that the author snips out all but the two most recent entries in git log
’s output manually. This is strange because the command git log -2
does the same thing, without intervention from the user.
Chapter 9, ‘Three-Way Merges’, was a challenging chapter for me. It introduced changes that required the user’s intervention when a merge was to be performed. In fairness, the book’s examples worked on the ‘Rainbow’ repositories. The naming of commits after colours became confusing for me. However, I think this chapter is one of the book’s strong points compared to other titles.
Chapter 10, ‘Merge Conflicts’, has quite a bit of theory and practical. There are a lot of things to remember and I continued making copious notes to help me get through this chapter. I used the custom bash prompt optimised for Git usage in part of Pro Git 2e [4] [5] and used a word processor to keep track of things – having a PDF of the book helped greatly for that. However, this chapter was very helpful in initially getting to grips with merge conflicts and how to resolve them.
Chapter 11, ‘Rebasing’, like other chapters, has theory and practical. It explains what rebasing is and when to not use it – because with this command you rewrite the commit history with a view to having fewer merge commits.
Chapter 12, ‘Pull Requests (Merge Requests)’, was interesting and had links to [1] which I used to get fuller information on GitHub’s pull requests [6]. To quote GitHub:
Pull requests are proposed changes to a repository submitted by a user and accepted or rejected by a repository’s collaborators.
In order to receive pull requests for my ‘Rainbow’ repo [7] I asked for help on accu-general [2] and was helped by Paul and Chaitanya accordingly. The help pages for the GitHub web GUI [6] proved very useful.
I have come to appreciate Git and it has become apparent that the only way to maintain Git skills is to regularly exercise them. My copy of this book is now held together with Magic Tape and I have a physical file of git help pages etc. This is a very good introduction to Git and I highly recommend it.
Website: https://www.oreilly.com/library/view/learning-git/9781098133900/
Code site: https://github.com/gitlearningjourney/learning-git
References
[1] https://github.com/gitlearningjourney/learning-git
[2] https://accu.org/faq/mailing-lists-faq/
[3] Michael W. Lucas, SSH Mastery (2e), ISBN 9781642350029
[4] Scott Cahon and Ben Straub, Pro Git (2e), ISBN 978-1-4842-0077-3
[5] https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash