Recall & Review
beginner
What does the command
git switch <branch-name> do?It changes your current working branch to the specified branch named <branch-name>.
Click to reveal answer
beginner
How do you create and switch to a new branch named
feature using git switch?Use
git switch -c feature. The -c flag creates the new branch and switches to it immediately.Click to reveal answer
beginner
What happens if you try
git switch to a branch that does not exist without the -c option?Git will show an error saying the branch does not exist and will not switch branches.
Click to reveal answer
intermediate
Why might you prefer
git switch over git checkout for switching branches?git switch is simpler and only focuses on switching branches, making it easier and less error-prone for beginners.Click to reveal answer
intermediate
What command would you use to switch back to the previous branch you were on?
Use
git switch - to quickly go back to the last branch you had checked out.Click to reveal answer
Which command switches to an existing branch named
dev?✗ Incorrect
Use
git switch dev to switch to an existing branch. The -c option creates a new branch.How do you create and switch to a new branch called
feature1?✗ Incorrect
The
-c flag creates a new branch and switches to it.What will happen if you run
git switch unknown-branch and the branch does not exist?✗ Incorrect
Git will show an error because the branch does not exist and will not switch.
Which command switches back to the previous branch you were on?
✗ Incorrect
The
- option switches to the last branch you were on.Why is
git switch recommended over git checkout for switching branches?✗ Incorrect
git switch focuses only on switching branches, making it simpler and less confusing.Explain how to switch to an existing branch and how to create and switch to a new branch using
git switch.Think about the difference between switching and creating branches.
You got /2 concepts.
Describe what happens if you try to switch to a branch that does not exist without creating it.
Consider what git expects when switching branches.
You got /3 concepts.