Skip to content

Branch Out, Level Up

We’ve been living a single, linear timeline — one commit after another.
But what if we want to try something new without breaking what’s working?

Welcome to branching, Git’s superpower for exploring alternate realities.


A branch isn’t a copy of your project — it’s just a pointer to a commit.
Think of it as a timeline bookmark that can grow in a new direction.

main ──●──●──●──●──▶
\
└──●──●──▶ feature/add-bio

💡 Each branch can move independently. When we switch branches, we’re essentially time traveling between versions of our code.


We create a new branch like this:

Terminal window
git branch feature/add-bio

That makes the branch, but doesn’t move us to it yet.
To hop timelines:

Terminal window
git switch feature/add-bio

Or do both in one step:

Terminal window
git switch -c feature/add-bio

Now we’re living on our new branch. 🎉


Edit files, add features, break things, and fix them again — all without touching main.

Let’s say we update index.html to add a new bio section:

<section id="bio">
<h2>Meet the Developer</h2>
<p>Professor Solo: lover of syntax, breaker of bugs.</p>
</section>

Then commit it:

Terminal window
git add index.html
git commit -m "Add bio section to homepage"

Now our branch has diverged from main — a safe space for creativity.


Once the branch is ready, we bring those changes home.

Terminal window
git switch main
git merge feature/add-bio

If no one else has changed the same lines, Git merges automatically — known as a fast-forward merge.

main ──●──●──●──●──●──●──▶
merged branch

We can now safely delete the branch:

Terminal window
git branch -d feature/add-bio

Git keeps the history, even after the branch itself is gone.


Sometimes, two branches change the same file in different ways.
That’s when Git taps us on the shoulder:

<<<<<<< HEAD
<p>Welcome to the Web Dev TnT Lab!</p>
=======
<p>Welcome to the Professor Solo Experience!</p>
>>>>>>> feature/add-bio

We fix the conflict manually — choose what stays, what goes, or even combine both — then:

Terminal window
git add index.html
git commit

💡 Professor Solo’s Pro Tip:
Merge conflicts aren’t failures — they’re conversations between timelines.


Good branch names make collaboration clear:

TypePrefixExample
New featurefeature/feature/add-contact-form
Bug fixfix/fix/nav-hover-color
Hotfixhotfix/hotfix/login-error
Docsdocs/docs/update-readme
Releaserelease/release/2.0.0

💡 Use kebab-case (all lowercase, hyphen-separated).
Avoid spaces, punctuation, and emojis — no matter how tempting.


List all local branches:

Terminal window
git branch

See remote branches too:

Terminal window
git branch -r

And view the branch graph with:

Terminal window
git log --oneline --graph --decorate --all

This command shows all the project’s timelines at once — the Git multiverse.


We can now:

  1. Create and switch branches (git switch -c branch-name)
  2. Merge changes back into main (git merge)
  3. Resolve conflicts gracefully
  4. Follow naming conventions for clarity
  5. Visualize and manage multiple timelines at once

💡 Professor Solo says:

“Branching isn’t about breaking things — it’s about building boldly.
Explore your what-ifs, then merge your masterpieces.”