Tech

Git Branch

Keeping the master notebook safe while scribbling freely on a fresh photocopy split off from that moment.

  • 3 min read
  • 1 figures
  • Verified 2026-10-11

Definition

In Git, a version control system for code, a branch is an independent line of work split off from the main line. It inherits the entire project history up to that point so you can build new features on top of it. Because the main line stays untouched, you can always scrap your changes and return to where you started if something goes wrong.

Writing on a Photocopy to Protect the Original Notebook

Imagine making a class yearbook with your classmates. Everyone takes turns writing stories into a single notebook. Now suppose you want to try out a brand-new story idea.

Writing directly into the master notebook is risky. If it turns out poorly, erasing and rewriting leaves smudges that ruin the earlier pages. Instead, you photocopy the notebook up to the current page, slide the copy into a new binder, and experiment there to your heart's content.

In Git, this experimental copy is called a branch. The moment you create it, it looks identical to the original, but any new writing only goes onto your copy. The original stays completely untouched.

The main trunk itself is actually just another branch. People usually call it the main branch, and everyone treats it as the polished, finished version of the project.

Working in Parallel, Then Bringing It All Together

Nobody builds a yearbook alone. Multiple teammates take their own photocopies and draft different chapters simultaneously. No matter what the person next to you writes, your copy remains undisturbed.

When someone finishes their section, they paste it back into the master notebook. In Git, combining work from a branch back into the main line is called a merge. From that point on, their work becomes part of the shared master version.

Trouble brews when two people edit the exact same sentence in different ways. If one expanded the sentence while the other deleted it entirely, a human has to step in and decide which version to keep. Git calls this clash a merge conflict. If people edited different parts of the file, Git weaves them together automatically. But when changes overlap in the same spot, Git stops and asks for human judgment.

That is why holding onto a branch for too long makes merging painful: the master version changes too much in the meantime. Breaking work into small pieces and merging often makes life much easier.

A Closer Look Under the Hood

In reality, Git does not duplicate the whole notebook. A branch is really just a movable sticky note pointing to the latest page of that timeline. Every time you write a new page, the sticky note simply slides forward to the new page.

Because of this, creating a branch takes practically no time or memory. You are just slapping on a new sticky note. Developers routinely create dozens of branches a day and delete them just as easily once their purpose is served.

There is one closely related term people often mix up: a commit is a single saved snapshot—a single page in that notebook. A branch is the named timeline tracing those pages together.

So there is no need to view a branch as an intimidating parallel universe. It is simply a safe way to mark your starting point, step aside to tinker with code without fear, and rejoin the team when you are ready.

Common misconceptions

Myth

Creating a branch duplicates the entire project folder and hogs disk space.

Fact

A branch is merely a pointer to a specific commit. Because Git does not clone all project files for each branch, creating or deleting one is virtually instantaneous and uses almost zero disk space.

Myth

Making changes on a branch immediately modifies the code on the main branch.

Fact

Work done on a branch stays isolated on that branch. Changes only affect the main line once you deliberately merge them back in.

Where you meet it

  1. When building a new checkout screen for an e-commerce app, developers leave the live production code untouched and work strictly inside a dedicated feature branch.

  2. When users report a critical display bug, engineers create a separate hotfix branch, patch the error, and merge it straight back into the main line.

In one sentence

An isolated line of work that branches off from your project history, allowing you to build and test new features without risking the original code.

Created 2025-08-28 Updated 2026-10-11 Verified 2026-10-11