Choose Between git switch, git checkout, and git restore

Understand how the modern Git CLI splits branch changes, file restores, and power workflows.

Overview

Git now offers focused commands so you can express intent clearly: git switch for branch changes, git restore for file cleanups, and git checkout for advanced moves.

Recommended defaults

  • git switch <branch> moves between branches without touching your worktree files.
  • git switch -c <branch> creates a new branch from the current commit, just like git checkout -b used to.
  • git restore <path> reverts file changes in your working tree, and git restore --staged unstages files.

Splitting responsibilities reduces accidental file resets when you only meant to hop branches.

When git checkout still shines

  • Detached HEAD work: git checkout <commit> still provides a quick way to inspect old snapshots.
  • One-off resets: git checkout -- . remains a shorthand to drop every local change at once.
  • Fallback muscle memory: older scripts and aliases may still rely on checkout, so it stays for backward compatibility.

Use it when you intentionally need these advanced patterns; otherwise reach for the dedicated commands above.

Related scenarios