0
0
Gitdevops~20 mins

git stash apply vs pop - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Stash Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Difference between git stash apply and git stash pop

Which statement correctly describes the difference between git stash apply and git stash pop?

A<code>git stash apply</code> creates a new stash; <code>git stash pop</code> only shows the stash contents.
B<code>git stash apply</code> reapplies the stash but keeps it in the stash list; <code>git stash pop</code> reapplies and removes the stash from the list.
C<code>git stash apply</code> deletes the stash without applying it; <code>git stash pop</code> applies the stash but keeps it in the list.
D<code>git stash apply</code> permanently deletes all stashes; <code>git stash pop</code> restores the last commit.
Attempts:
2 left
💡 Hint

Think about whether the stash remains after applying it.

💻 Command Output
intermediate
1:30remaining
Output after using git stash pop

You have one stash saved. You run git stash pop. What happens to the stash list?

AThe stash is reapplied and removed from the stash list, leaving the list empty.
BThe stash is reapplied but remains in the stash list.
CThe stash list is cleared without applying any changes.
DAn error occurs because <code>git stash pop</code> cannot be used with one stash.
Attempts:
2 left
💡 Hint

Remember what pop means in everyday life: to take something out.

Troubleshoot
advanced
2:00remaining
Resolving conflicts after git stash pop

You run git stash pop and get a conflict error. What is the best next step?

ARun <code>git stash apply</code> again to fix the conflicts automatically.
BRun <code>git reset --hard</code> to discard all changes and conflicts.
CManually resolve the conflicts in the files, then run <code>git add</code> and <code>git commit</code>.
DRun <code>git stash drop</code> to remove the stash and ignore the conflicts.
Attempts:
2 left
💡 Hint

Conflicts need manual attention before continuing.

🔀 Workflow
advanced
1:30remaining
Choosing between git stash apply and git stash pop in a workflow

You want to test changes saved in a stash but keep the stash for later use if needed. Which command should you use?

AUse <code>git stash apply</code> to reapply changes without removing the stash.
BUse <code>git stash pop</code> to reapply and remove the stash immediately.
CUse <code>git stash drop</code> to remove the stash without applying it.
DUse <code>git stash clear</code> to remove all stashes before applying.
Attempts:
2 left
💡 Hint

Think about whether you want to keep the stash after testing.

Best Practice
expert
2:30remaining
Best practice to avoid losing stashed changes accidentally

Which practice helps avoid losing stashed changes when using git stash pop?

AUse <code>git stash clear</code> regularly to keep the stash list clean.
BAlways use <code>git stash pop</code> directly to save time and avoid extra commands.
CNever use stashes; commit all changes immediately to avoid confusion.
DUse <code>git stash apply</code> first to test changes, then <code>git stash drop</code> after confirming success.
Attempts:
2 left
💡 Hint

Think about how to keep a backup until you are sure changes are good.