Interview Prep/Git & GitHub/Commits, branches and tags

What is the difference between `git switch`, `git restore` and `git checkout`?

BeginnerConceptCommits, branches and tags
Answer

checkout is the older overloaded command that both changes branches and restores files. Git 2.23 split it: git switch only changes branches, git restore only restores file content from the index or a commit. Prefer the new ones for clarity.

git switch -c feature/x
git restore --staged app.py
git restore --source=HEAD~2 app.py
All Git & GitHub questions Roadmap: Git & GitHub

More on Commits, branches and tags