Challenge - 5 Problems
Git Switch Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of switching to an existing branch
What is the output when you run
git switch feature-xyz if the branch feature-xyz exists and you have no uncommitted changes?Attempts:
2 left
💡 Hint
Think about what git says when you successfully switch branches.
✗ Incorrect
When you switch to an existing branch with no uncommitted changes, git confirms by saying 'Switched to branch '.
💻 Command Output
intermediate1:30remaining
Error when switching to a non-existent branch
What error message appears when you run
git switch non-existent-branch and the branch does not exist?Attempts:
2 left
💡 Hint
Git tells you when the branch name is unknown.
✗ Incorrect
If the branch does not exist, git reports 'error: pathspec did not match any file(s) known to git'.
🔀 Workflow
advanced1:30remaining
Creating and switching to a new branch in one command
Which command correctly creates a new branch named
hotfix and switches to it immediately?Attempts:
2 left
💡 Hint
The option to create a branch with git switch is a single letter.
✗ Incorrect
The correct syntax to create and switch to a new branch is 'git switch -c '.
❓ Troubleshoot
advanced1:30remaining
Error when switching branches with uncommitted changes
What error message will you get if you try to run
git switch develop while having uncommitted changes that conflict with the develop branch?Attempts:
2 left
💡 Hint
Git warns about overwriting local changes when switching branches.
✗ Incorrect
Git prevents switching branches if local changes would be overwritten and shows an error listing the conflicting files.
🧠 Conceptual
expert2:00remaining
Behavior of git switch with detached HEAD
What happens when you run
git switch --detach without specifying a branch or commit?Attempts:
2 left
💡 Hint
Think about what 'detached HEAD' means in Git.
✗ Incorrect
Running 'git switch --detach' without arguments detaches HEAD at the current commit, letting you explore without changing branches.