0
0
Gitdevops~20 mins

Dropping and clearing stashes in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Stash Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of dropping a stash by name?
You have a stash named stash@{1}. What is the output of the command git stash drop stash@{1}?
Git
git stash drop stash@{1}
Aerror: stash 'stash@{1}' not found.
BDropped stash@{1} (some message about the stash)
CNothing to drop, stash list is empty.
Dfatal: ambiguous argument 'stash@{1}': unknown revision or path not in the working tree.
Attempts:
2 left
💡 Hint
Dropping a stash by its exact name removes it and confirms the action.
💻 Command Output
intermediate
2:00remaining
What happens when you clear all stashes?
What is the output of running git stash clear when you have multiple stashes saved?
Git
git stash clear
AAll stashes cleared silently with no output.
Berror: stash list is empty, nothing to clear.
CCleared 3 stashes successfully.
Dfatal: stash clear is not a git command.
Attempts:
2 left
💡 Hint
Clearing stashes removes all without confirmation or output.
Troubleshoot
advanced
2:00remaining
Why does git stash drop fail with ambiguous argument error?
You run git stash drop stash@{foo} and get the error: fatal: ambiguous argument 'stash@{foo}': unknown revision or path not in the working tree. What is the most likely cause?
Git
git stash drop stash@{foo}
AYour git version does not support dropping stashes by name.
BYou need to run <code>git stash clear</code> first to reset stashes.
CThe stash name 'stash@{foo}' does not exist or is invalid.
DYou must specify the stash index as a number, not a string.
Attempts:
2 left
💡 Hint
Check if the stash name matches an existing stash exactly.
Best Practice
advanced
2:00remaining
What is the safest way to remove a specific stash without affecting others?
You want to remove only the stash at index 2 without touching others. Which command should you use?
Agit stash apply stash@{2} && git stash drop stash@{2}
Bgit stash clear
Cgit stash pop stash@{2}
Dgit stash drop stash@{2}
Attempts:
2 left
💡 Hint
Dropping a stash by its exact name removes only that stash.
🔀 Workflow
expert
3:00remaining
Order the steps to safely clear all stashes after backing them up
You want to save all current stashes as patches before clearing them. Put the steps in the correct order.
A1,2,4,3
B1,4,2,3
C2,1,4,3
D1,3,2,4
Attempts:
2 left
💡 Hint
List stashes first, export each, then clear.