Challenge - 5 Problems
Git Branch Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of creating a new branch?
You run the command
git branch feature1 in a repository. What will be the output shown in the terminal?Git
git branch feature1Attempts:
2 left
💡 Hint
The
git branch command creates a branch but does not switch to it.✗ Incorrect
The git branch feature1 command creates a new branch named feature1 silently without switching to it or showing output.
💻 Command Output
intermediate1:30remaining
What branches exist after creating a branch?
You have a repository with a single branch
main. You run git branch dev. What branches will git branch list now?Git
git branch dev git branch
Attempts:
2 left
💡 Hint
The star (*) marks the current branch.
✗ Incorrect
After creating dev branch, the current branch remains main. So git branch lists * main and dev.
🔀 Workflow
advanced2:00remaining
Which command sequence creates and switches to a new branch?
You want to create a new branch called
featureX and start working on it immediately. Which sequence of commands achieves this?Attempts:
2 left
💡 Hint
Creating a branch and switching are two separate steps unless combined.
✗ Incorrect
git branch featureX creates the branch, then git checkout featureX switches to it. Option A is a shortcut but not a sequence.
❓ Troubleshoot
advanced1:30remaining
Why does
git branch fail to create a branch?You run
git branch main but get the error: fatal: A branch named 'main' already exists. What is the cause?Attempts:
2 left
💡 Hint
Branch names must be unique in the repository.
✗ Incorrect
The error means the branch main already exists. Git does not allow duplicate branch names.
🧠 Conceptual
expert2:30remaining
What happens internally when you run
git branch new-feature?Choose the correct description of what
git branch new-feature does internally in the git repository.Attempts:
2 left
💡 Hint
Think about what a branch really is in git.
✗ Incorrect
A branch in git is a pointer to a commit. The command creates a new pointer to the current commit but does not move HEAD or switch branches.