git-checkout
TLDR
Switch to branch
SYNOPSIS
git checkout [options] branch|commit|file
DESCRIPTION
git checkout switches branches or restores files. It updates the working tree to match the specified branch, commit, or file version from history.
The command serves multiple purposes: branch switching, branch creation, file restoration, and detached HEAD operations. Modern git prefers git switch for branches and git restore for files.
git checkout remains widely used for its versatility.
PARAMETERS
BRANCH
Branch to switch to.-b BRANCH
Create and switch to new branch.-t, --track
Set up tracking for remote branch.-- FILE
Restore file from index.-f, --force
Force switch, discard changes.--orphan BRANCH
Create orphan branch.--help
Display help information.
CAVEATS
Uncommitted changes may be lost with -f. Detached HEAD requires care. Consider git switch/restore for clarity.
HISTORY
git checkout is an original Git command that combines several operations. Git 2.23 introduced git switch and git restore as clearer alternatives.
SEE ALSO
git-switch(1), git-restore(1), git-branch(1)


