Skip to content
Back to library
beginnerBranches & HEAD

Checkout

The Definition

The git checkout command switches branches or restores working directory files.

Mental Model

"Checking out is like time travel. You move HEAD to point at a different branch or commit, and your working directory updates to match that snapshot."

Visual Simulation

Live Engine
HEAD
Files on Main
Files on Feature

Watch Out (Common Pitfalls)

!

Not understanding that uncommitted changes will be carried over or cause conflicts

!

Using checkout for files vs branches - the behavior is different

!

Forgetting that checkout switches your working directory files

Hands-on Command

shell
~ $git checkout main git checkout feature-branch