Recall & Review
beginner
What does the command
git branch do?It lists all the branches in your repository and shows which branch you are currently on.
Click to reveal answer
beginner
How do you create a new branch named
feature using git?Use the command
git branch feature to create a new branch called feature.Click to reveal answer
beginner
Does
git branch new-branch switch you to the new branch?No, it only creates the branch. You stay on the current branch until you use
git checkout new-branch or git switch new-branch.Click to reveal answer
intermediate
What command creates and switches to a new branch in one step?
Use
git checkout -b branch-name or git switch -c branch-name to create and switch to a new branch at once.Click to reveal answer
beginner
Why use branches in git?
Branches let you work on different features or fixes separately without changing the main code. It’s like having separate workspaces for different tasks.Click to reveal answer
What does
git branch without arguments do?✗ Incorrect
git branch alone lists all branches and highlights the current one.
Which command creates a new branch called
dev?✗ Incorrect
git branch dev creates a new branch named dev without switching to it.
After running
git branch feature, what is your current branch?✗ Incorrect
The command creates the branch but does not switch to it, so you stay on your current branch.
Which command both creates and switches to a new branch named
test?✗ Incorrect
git checkout -b test creates and switches to the test branch in one step.
Why is branching useful in git?
✗ Incorrect
Branches let you work on different features or fixes without affecting the main code.
Explain how to create a new branch and switch to it in git.
Think about commands that create and switch branches.
You got /4 concepts.
Why should you use branches when working with git?
Imagine working on different projects at the same time.
You got /4 concepts.