Old Commands You'll See Online
Git checkout.
When you search for Git help online, you'll often see a command called git checkout. It's older than switch and restore, and it does both jobs. It still works perfectly, so it's worth recognising.

- Online answers use git checkout
- Older than switch and restore
- It does both jobs
Old and new
Here's the translation. Git checkout, a branch, is the same as git switch. Checkout dash b is switch dash c. Checkout, dash dash, and a file, is git restore. And reset head, and a file, is restore dash dash staged. Switch and restore were added in twenty nineteen, to make things clearer.
| Older command | Newer equivalent |
|---|---|
| git checkout main | git switch main |
| git checkout -b dark | git switch -c dark |
| git checkout -- file | git restore file |
| git reset HEAD file | git restore --staged file |
Checkout still works
Let's prove it. Git checkout dash b creates and switches, exactly like switch dash c. Checkout main switches back. Then we make a quick edit. Checkout, dash dash, index dot HTML throws it away, exactly like git restore. Status is clean.
git checkout -b dark Switched to a new branch 'dark' git checkout main Switched to branch 'main' echo 'oops' >> index.html git checkout -- index.html git status --short
Summary
Git checkout is the older command for both switching and restoring. Now you can read any online answer. Next, the old name for the main branch.
Key takeaways- checkout = switch + restore
- checkout -b = switch -c
- Both still work