🔖 Branches: bookmarks, not copies

By the end of this page, a branch will be the simplest thing in git: a tiny movable label, never a second copy of your project.

1The sentence nobody tells beginners

When most people hear the word "branch," they picture git duplicating their whole project: a second folder, a second set of files, twice the stuff on disk. That picture causes more confusion than anything else in git. So here is the sentence nobody says early enough:

A branch is not a copy of your project.

It is worth saying again, because your brain will try to sneak the wrong picture back in. A branch is not a copy of your project. It is a bookmark: a tiny label whose entire job is to say "the newest save point of this line of work is that one right there." That is all it stores. One little pointer.

🔖 A branch is a bookmark clipped to one photo in your album. Clipping a second bookmark to the album does not reprint a single photo. The photos stay exactly where they are. You just gain another little tab that says "this spot matters."

2Three bookmarks, one bead

Let's look at something real. These are two actual save points from your own project, the newest beads on your string. Right now, three different bookmarks are all clipped to the very same bead.

older saves db039fb review fixes f30f6b7 todo update the official version main origin/main what GitHub had, last sync HEAD you are here

This is your project right now: three bookmarks, one bead. The green main bookmark marks the official line of work. The amber HEAD bookmark means "you are standing here." The violet origin/main bookmark remembers where main was on GitHub the last time your computer talked to it. When all three sit on the same bead, life is calm: you are on the official line, and as far as your computer knows, GitHub is fully up to date.

3Bookmarks move by themselves

Here is the part that makes branches feel almost magical. You never push these bookmarks around by hand in daily work. They slide forward on their own.

Whenever you take a new photo of your project, a new bead appears on the string, and the bookmark you are standing on slips forward onto that new bead automatically. Think of the "you are here" pin on a mall map that follows you as you walk. You walk, it moves. You save, the bookmark moves.

So "being on main" simply means: every new save point you make becomes the new tip of main, and the green bookmark glides forward to sit on it. No dragging, no ceremony.

4Why make more bookmarks?

Because sometimes you want to try an idea without disturbing the official line. Maybe a redesign, a risky cleanup, a wild experiment. You clip a new bookmark, call it my-experiment, onto the same bead main is on. Nothing is copied. Nothing changes yet. You just gained a second tab.

Then you start saving. Your new beads grow under the experiment bookmark, which slides forward with each save, exactly like before. And main? Main does not budge. It stays clipped to the last official save, completely undisturbed.

836f2de finished content db039fb review fixes f30f6b7 todo update main my-experiment a brand new bookmark, same bead, nothing copied 3c9aa21 first try 8d04e5f second try my-experiment

Main never moved; your experiment grew beside it. If the idea works out, you can fold it back into the official line later, and we will do exactly that in a coming lesson. If it flops, you simply walk away. The official line never felt a thing.

5Deleting a branch deletes... a bookmark

This is the calmest fact on the page. When you delete a branch, you remove a bookmark, nothing more. No pages get torn out of the book. The save points themselves stay safe on the string, as long as some bookmark, or the chain leading back from one, can still reach them. Remember the promise from earlier lessons: committed work is almost impossible to lose.

🔖 Pulling a bookmark out of a book never rips out the pages. Your project is a book that is still being written. Take out a bookmark and the chapters are all still there; you have only lost one quick way of jumping to a spot.

6Git's words for all this

🗣 Git's word for a bookmark is a "branch." The amber "you are here" bookmark is called HEAD. The default branch is usually called main: GitHub names it that for every new project, though plain git on your Mac may still say "master" out of the box (same idea, different label). Creating a branch is instant, because git writes one tiny label, a scrap of text about 41 bytes long. Nothing is copied, ever.

You will create branches by hand in your practice playground soon. Here is a sneak peek at the spell, so it looks familiar when it arrives:

# inside a practice repo like /tmp/git-playground
git switch -c my-experiment
Switched to a new branch 'my-experiment'
# older guides say: git checkout -b my-experiment  (same thing, older word)

That command did two tiny things: it wrote one new bookmark on the current bead, and it moved HEAD onto it. Total cost: a blink.

7Check yourself

Q. When you create a branch, git...

A branch is just a bookmark: one tiny label, about 41 bytes, that points at a save point. That is why creating one is instant and why nothing on your disk gets duplicated. Sending work to GitHub is a separate action called pushing, which comes later in the course.

Q. A teammate deletes a branch. Is the work on it destroyed?

Usually no. Deleting a branch removes a bookmark, not the save points. The beads only become unreachable if no bookmark at all can walk back to them, and even then git quietly keeps them around for a while, so they can almost always be rescued.
🧠 If you remember one thing: branches are 41-byte sticky notes: cheap to make, safe to delete, and never copies of your project.