Lesson 5
Writing Reusable and Self-explanatory Programs
Chapter 8: git branch
git branch
In a while, you will be attempting to make your robot project much much more readable!
But let’s take a break from Python for a moment.
Instead, we’ll with explore more git
goodness.
In this chapter, you will be looking at the concept of branch
es in git
.
What is a git branch?
A git
branch is just a pointer to your latest commit. Think of the pointer as the tip
of a branch.
Each branch has a name (main
in the example below). You can rename a branch any time.
You can also trace your commit history on your branch (commits 1, 2, and 3 in the image above).
Multiple branches
You can have multiple branches in your repo, each with its own name.
In the figure above, you have two branches (main
and feature
).
The main
branch points to commit 6, and you can visualise its history of commits (4, 3, 2 and 1).
The feature
branch points to commit 8, with a history of commits 7, 5, 3, 2 and 1.
HEAD
You can switch between different branches at any time.
The HEAD
pointer tells you which branch you are currently working on.
In the example below, you are currently working on the feature
branch.