This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 6: An army of robots

Git branch recap

face Josiah Wang

We have covered quite a lot on Git in the previous lesson, so we will do just a small Git activity in this lesson.

Let us first recap git branch from the previous lesson.

Recall that a git branch is a named pointer to your latest commit.

A git repo can have multiple branches. Each branch has a name, and points to the ‘tip’ (last commit) of that branch.

You can switch between branches at any time. The HEAD pointer tells you which branch you are currently working on.

HEAD

Also recall that git checkout will move the HEAD pointer to the branch you specify, and also update the files in your working directory to show the latest commit in this branch. Sort of like checking out your grocery shopping from your shopping basket/trolley into your shopping bag at the checkout counter.

user@MACHINE:~/robot$ git checkout refactor
Switched to branch 'refactor'
user@MACHINE:~/robot$ git branch
  main
* refactor