Switch branches or restore files
medium risk
git stash push -uStash firstgit switch <branch>Use switch for branchesgit restore --staged <file>Use restore for filesOlder multi-purpose command; prefer git switch / git restore.
| Flag | Meaning |
|---|---|
-b | Create and switch |
-- | Restore paths from index⚠ Discards unstaged changes. |
git checkout -b feature/xNew branch · explain & risk-check →git checkout -- file.txtDiscard changes in a file · explain & risk-check →Reference text is hand-written and may be incomplete — check man git for your version. Test destructive commands on a non-production system first.