AI Hints
Git & GitHub · Lesson 39 of 144

What a Branch Is

A separate line of work.

⏱ 2 min read▶ Video at 42:13🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

A branch is a separate line of work. It lets you try something new, like a dark mode for your site, without touching the version that already works. If the idea works out, you bring it back. If not, you just throw the branch away.

What a Branch Is
From the video: What a Branch Is
  • A separate line of work
  • Try ideas safely
  • Keep them, or throw them away

Branches as lines

Here's our history, three commits on main. Main is the default branch. Now we create a branch called dark, starting from the latest commit. When we commit on dark, main doesn't move at all. Dark grows on its own line. And main can keep growing too, completely separately.

Why branches are great

Branches are cheap. Creating one is instant, and takes almost no space. They keep main safe, so main always works. And they let several people work on different things at the same time, without getting in each other's way.

Cheapinstant to create
Safemain keeps working
Parallelmany ideas at once
Disposabledelete failed ideas

Summary

A branch is a separate line of commits. Main stays safe while you experiment. Next, creating and switching branches.

Key takeaways
  • A branch = a line of work
  • main is the default
  • Branches are cheap
Next up: Creating and Switching — git branch and git switch