git switch
The modern, focused way to change branches.
git switchWhat it does
git switch (Git 2.23+) is the same HEAD-moving mechanism as git checkout, stripped of the file-restoring half. It only changes which branch you're on — no accidental intent mixing, no hidden file-revert foot-guns.
git switch only moves HEAD between branches — nothing else
Watch it — press play
A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.
Step 1
A focused checkout
SWITCH is checkout's branch-only half. One job: move HEAD between branches.
git switch featureUnder the hood
Purely a HEAD + worktree operation
Like checkout, switch rewrites .git/HEAD and synchronizes the working tree. The difference is conceptual: the command refuses to guess about files, keeping one job per command.
-c creates, then switches
`git switch -c feat` is two steps under the hood: `git branch feat` (write the ref file) followed by switching HEAD to it. Identical to checkout -b, but scoped and predictable.
Command anatomy
-c <name>Create the branch, then switch to it.
-Switch to the previously checked-out branch (toggle).
-fDiscard local changes and switch anyway.
-t <remote/branch>Create a local branch that tracks the given remote one.
When to reach for it
Your daily branch-jumping — cleaner intent than checkout.
Quickly bouncing between two branches with `git switch -`.
Onboarding: newcomers learn switch + restore, never the legacy checkout split.
Practice
A real repo, pre-seeded with history, runs right here — stage, commit, branch, stash, diff, even hit and resolve a real merge conflict. Nothing to install, nothing leaves your machine.
Open practice playground