There are two separate code bases in this book, and they have their own branches: appointments and spec-logo. Chapter 1 to Chapter 9 cover appointments; Chapter 10 to Chapter 14 cover spec-logo. (Chapter 15 doesn't have any code.)
If you were to check out these branches, you'd get the final, completed versions of the code. This is an interesting sneak peak but it's not how you'll get started.
Instead, many sections have a designated tag, so you can skip to the tag and examine the code at that point. If you see a callout like this:
The Git tag for this section is animation.
...then you can skip to this tag by issuing the following command:
git checkout tags/animation
Once you've output that command, you will be in the detached head state. If you want to begin making changes at that point, you should create a new branch from the tag and work on that. I'd suggest suffixing the name with -mine so that your branches are clearly distinguishable from tags:
git checkout -b animation-mine
You can then commit to this branch. If you have been following along judiciously within your own branch, then you do not need to check out each tag, since you'll already have all of the same code.
However, sometimes you will see a callout like the one that follows, and that means you will need to check out the new tag:
The Git tag for this section is load-available-time-slots. It contains solutions to the exercises from the previous chapter, so if you haven't completed the Exercises section yourself, then you should move to this tag now so that you're up to date.
For more detailed instructions, see the To get the most out of this book section in the Preface.
This type of callout means that the code base now contains additional changes since the last edits covered in the book. It often happens at the start of each chapter when the preceding chapter had exercises, but it also happens when the code base skips ahead with changes that are uninteresting or not related to the content of the book.
When you see this callout, you have two options:
- You can choose to check out the new tag and start a new branch, starting afresh. In this case, the instructions are the same as before, except now you'd need a different branch name from your existing branch:
git checkout tags/load-available-time-slots
git checkout -b load-available-time-slots-mine
- You can choose to continue working on the branch you have. This could be because you've been creative and made changes that aren't covered in the book (which I fully support). In this case, git diff and git merge are your friends. You will want to review the changes in the latest tag, and then git merge them in. You may need to handle conflicts:
# to view the differences in the new tag
git diff tags/load-available-time-slots
# to auto-merge those differences into your branch
git merge tags/load-available-time-slots
The second option is not entirely risk free, mainly due to the Exercises section at the end of each chapter.