Checkout vs switch
Separate switching branches from restoring files.
Switch says what you mean
git switch changes branches. -c creates a branch and switches to it. Git 2.23 introduced switch and restore; older versions may need checkout.
git switch main
git switch -c feature/menuCheckout has several jobs
Checkout can switch branches or restore paths. That overload makes beginner mistakes easier. The double dash separates paths from revisions in path-checkout commands.
git checkout main
git checkout -b feature/menuUse restore for a file
A file operation is not a branch operation. Restoring a working file can overwrite uncommitted edits. Inspect status and diff before doing it.
git status
git diff -- notes.txt
# Only if you intend to discard those working-file edits:
git restore notes.txtDetached HEAD is a separate choice
Switch --detach COMMIT_SHA deliberately checks out a commit without a normal branch. Before making new work there, create a branch so your commits have a durable name.
Quick check
Which command creates and switches to a branch?
Choose an answer.
Sources and scope
Command blocks are syntax examples checked against official documentation, not fabricated terminal output. Replace uppercase placeholders with your actual names and inspect status before commands that change work.