🎓 A1Learner
🔍
0 of 50 lessons completed

What Is a Branch

A branch is a line of work. It lets you try an idea without touching the main line.

List the branches

Only one branch exists. The star says you are on it.

$ git branch

One line of work

The history is one straight line. One branch, one line.

$ git log --graph --oneline

Example

$ git branch

Key points

  • The main line is called main.
  • A branch starts at one snapshot and grows its own snapshots.
  • Work on one branch never touches another branch.
  • The branch command lists the branches you have.
  • A star marks the branch you are on.
  • Switching branches changes the files to match that branch.
  • Branches are cheap. Make one for every idea.

Here, only one branch exists. It is called main, and the star says you are on it.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What is a branch?