Junior Version Control

What is a branch in Git, and why are branches useful?

A branch in Git is like a separate line of development — a parallel universe for your code. It

allows you to work on new features, bug fixes, or experiments without affecting the main

codebase (usually called the main or master branch).

Why branches are useful:

They make collaboration easier by keeping each developer’s work isolated until it’s ready to

be merged back.

Follow:

Real-world example:

Imagine your company website is live, but you need to add a “dark mode” feature. Instead

of editing the main code directly (which might break the live site), you create a new branch

called feature/dark-mode to work independently. Once it’s done and tested, you merge it

back into main.

More from Developer Essentials

All questions for this course