World map

 

BM: Baca dalam Bahasa Melayu

World 3: Parallel Universes

The old way: git checkout

You will learn: to read old guides that use git checkout for branches.

The problem

git checkout -b fix-typo prints: Switched to a new branch 'fix-typo'. Terminal output: $ git checkout -b fix-typo Switched to a new branch 'fix-typo'

An old guide says git checkout -b. Your friend says git switch -c. Who is right?

Watch

HEAD jumps from main onto the dark-mode note, just like with git switch.
6d3a9b1a8feb63270a76e

Both are right! git checkout dark-mode works like git switch dark-mode. And git checkout -b works like git switch -c.

Try it

Build the old way to make fix-typo and hop onto it.

Tap the pieces in the right order.

…

Try it

You are on dark-mode. Go back to main, the old way.

6d3a9b1a8feb63270a76e

Check

Old git checkout did two jobs. Which new command does each job now?

Drag a card into a box. Or tap the card, then tap the box.

      Predict

      Git 3.0 is coming. Will it remove git checkout?

      Pick one answer.

      You did it!

      You can now read old guides that use git checkout.

      Go deeper (optional)

      git checkout does two jobs: branches and files. That mix confused people. So Git 2.23 added git switch for branches and git restore for files. Careful: git checkout -- file throws away your changes, like git restore. Prefer the new commands. They say what they do.