0
0
Gitdevops~20 mins

git stash to save changes - Practice Problems & Coding Challenges

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!
💻 Command Output
intermediate
1:30remaining
What is the output of git stash list after stashing changes?
You have modified files in your git repository. You run git stash to save your changes temporarily. What will git stash list show immediately after?
Git
git stash

git stash list
Astash@{0}: WIP on main: <commit-hash> Your last commit message
BNo stash entries found.
Cfatal: No stash found.
DError: stash command not recognized.
Attempts:
2 left
💡 Hint
Think about what git stash does and how git stash list displays saved stashes.
🧠 Conceptual
intermediate
1:30remaining
What happens to your working directory after running git stash?
You have uncommitted changes in your working directory. You run git stash. What is the state of your working directory immediately after?
AWorking directory is partially cleaned; only staged changes are saved.
BChanges remain in the working directory but are also saved in stash.
CChanges are deleted permanently from the working directory and stash.
DAll changes are saved and the working directory is clean, matching the last commit.
Attempts:
2 left
💡 Hint
Consider what stash means: saving changes temporarily and cleaning your workspace.
🔀 Workflow
advanced
2:00remaining
Which sequence of commands correctly saves changes and then applies them back?
You want to save your current changes temporarily and later bring them back. Which command sequence does this correctly?
A
git stash create
...
git stash drop
B
git stash
...
git stash apply
C
git stash save
...
git stash pop
D
git stash store
...
git stash branch
Attempts:
2 left
💡 Hint
Remember the basic commands to save and reapply stashed changes.
Troubleshoot
advanced
1:30remaining
What error occurs if you run git stash apply with no stashes saved?
You run git stash apply but you never saved any stash before. What error message will git show?
Git
git stash apply
ANo stash found.
Bfatal: You do not have the initial commit yet
Cfatal: bad revision 'stash@{0}'
Derror: Your local changes to the following files would be overwritten by merge
Attempts:
2 left
💡 Hint
Think about what happens when git tries to apply a stash that does not exist.
Best Practice
expert
2:00remaining
Which command safely saves changes including untracked files?
You want to stash your changes but also include new untracked files. Which command should you use?
Agit stash push -u
Bgit stash save --include-untracked
Cgit stash apply --all
Dgit stash store --untracked
Attempts:
2 left
💡 Hint
Look for the modern command to stash including untracked files.