Challenge - 5 Problems
Git Working Directory Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Identify clean working directory status
You run
git status in a repository. Which output indicates a clean working directory?Attempts:
2 left
💡 Hint
Look for the phrase that says no changes are pending.
✗ Incorrect
A clean working directory means no changes to commit or stage. Option D shows this exact message.
🧠 Conceptual
intermediate2:00remaining
Difference between staged and unstaged changes
Which statement correctly describes the difference between staged and unstaged changes in Git?
Attempts:
2 left
💡 Hint
Think about what 'git add' does.
✗ Incorrect
Staged changes are those added to the staging area with 'git add' and ready for commit. Unstaged changes are modified but not yet staged.
❓ Troubleshoot
advanced2:00remaining
Detecting dirty working directory with a script
You want to write a shell script to check if the Git working directory is dirty (has unstaged or staged changes). Which command correctly returns a non-empty output only if the directory is dirty?
Attempts:
2 left
💡 Hint
Use commands that list changed files and combine with OR to detect any changes.
✗ Incorrect
Option A lists unstaged and staged changed files. It outputs file names if dirty, empty if clean. Using OR (||) ensures any changes are detected.
🔀 Workflow
advanced2:00remaining
Handling dirty working directory before switching branches
You want to switch branches but your working directory is dirty. What is the safest way to switch branches without losing your changes?
Attempts:
2 left
💡 Hint
Think about saving your work temporarily.
✗ Incorrect
Using 'git stash' saves your changes safely so you can switch branches and reapply them later. Other options risk losing work.
✅ Best Practice
expert2:00remaining
Best practice for committing changes in a dirty working directory
You have multiple unrelated changes in your dirty working directory. What is the best practice to commit them properly?
Attempts:
2 left
💡 Hint
Think about how to organize commits clearly.
✗ Incorrect
Using 'git add -p' lets you stage parts of files interactively, enabling clean, focused commits. This improves history clarity.