link
git/checkout

Switch Branches

Switch branches or restore files

git
checkout
branch

Command

git checkout

Examples

Switch to main branch

git checkout main

Create and switch to new branch

git checkout -b new-branch

Discard changes to file

git checkout file.txt