Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is 'git stash' used for?
It temporarily saves your uncommitted changes so you can work on something else without losing your current work.
Click to reveal answer
beginner
How does stashing help when switching branches?
Stashing saves your changes so you can switch branches without committing incomplete work, then apply the changes later.
Click to reveal answer
intermediate
What happens to your changes after you run 'git stash'?
Your changes are saved in a hidden stack and your working directory is cleaned to match the last commit.
Click to reveal answer
intermediate
Can you stash multiple sets of changes in Git?
Yes, Git allows multiple stashes saved in a stack, which you can apply or drop individually later.
Click to reveal answer
beginner
What command restores your stashed changes back to your working directory?
The command 'git stash apply' restores the most recent stash without removing it from the stash list.
Click to reveal answer
What does 'git stash' do?
ASaves uncommitted changes temporarily
BDeletes all changes permanently
CCommits changes to the repository
DCreates a new branch
✗ Incorrect
'git stash' saves your uncommitted changes temporarily so you can work on something else.
After running 'git stash', what happens to your working directory?
AIt creates a new commit
BIt stays the same
CIt deletes the repository
DIt is cleaned to match the last commit
✗ Incorrect
The working directory is cleaned to match the last commit, removing your uncommitted changes temporarily.
Which command restores stashed changes without removing them from the stash list?
Agit stash apply
Bgit stash drop
Cgit stash pop
Dgit stash save
✗ Incorrect
'git stash apply' restores changes but keeps the stash in the list for later use.
Can you stash multiple sets of changes in Git?
AYes, but only two stashes
BNo, only one stash is allowed
CYes, multiple stashes are saved in a stack
DNo, stashing deletes previous stashes
✗ Incorrect
Git allows multiple stashes saved in a stack, which you can manage individually.
Why would you use 'git stash' before switching branches?
ATo commit changes automatically
BTo save incomplete work temporarily and switch safely
CTo delete the branch
DTo merge branches
✗ Incorrect
Stashing saves your incomplete work so you can switch branches without losing changes.
Explain how 'git stash' helps you manage unfinished work when you need to switch tasks quickly.
Think about saving your work without committing it.
You got /4 concepts.
Describe the difference between 'git stash apply' and 'git stash pop'.
One keeps the stash, the other removes it after restoring.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of git stash in Git?
easy
A. To merge two branches automatically
B. To permanently delete untracked files
C. To save your current changes temporarily without committing
D. To create a new branch from the current one
Solution
Step 1: Understand what git stash does
git stash saves your current working changes temporarily without committing them to the branch.
Step 2: Compare with other options
The other options describe different Git commands or actions unrelated to stashing.
Final Answer:
To save your current changes temporarily without committing -> Option C
Quick Check:
Stashing = Temporary save without commit [OK]
Hint: Stash = save work now, come back later [OK]
Common Mistakes:
Thinking stash commits changes permanently
Confusing stash with branch creation
Assuming stash deletes files
2. Which of the following is the correct command to save your current changes temporarily in Git?
easy
A. git save
B. git commit -m 'temp'
C. git push stash
D. git stash
Solution
Step 1: Recall the correct syntax for stashing
The correct command to save changes temporarily is git stash.
Step 2: Check other options for correctness
git save and git push stash are invalid commands. git commit -m 'temp' commits changes permanently, not temporarily.
Final Answer:
git stash -> Option D
Quick Check:
Temporary save command = git stash [OK]
Hint: Remember: stash means temporary save [OK]
Common Mistakes:
Using git save instead of git stash
Confusing commit with stash
Trying to push stash as a branch
3. Given the following commands run in order:
git stash git checkout main git stash pop
What happens after git stash pop?
medium
A. Your saved changes are restored and removed from stash
B. Your changes are permanently deleted
C. You switch back to the previous branch automatically
D. A new stash is created with the same changes
Solution
Step 1: Understand the commands sequence
git stash saves changes temporarily, git checkout main switches branch, and git stash pop restores saved changes and removes them from stash.
Step 2: Analyze the effect of git stash pop
This command applies the saved changes back to the working directory and deletes the stash entry.
Final Answer:
Your saved changes are restored and removed from stash -> Option A
Quick Check:
Stash pop = restore + remove stash [OK]
Hint: Pop restores stash and deletes it [OK]
Common Mistakes:
Thinking stash pop deletes changes permanently
Assuming branch switches back automatically
Believing stash pop creates a new stash
4. You ran git stash but later realize your changes are missing after switching branches. What is the most likely mistake?
medium
A. You forgot to run git stash pop to restore changes
B. You committed the changes instead of stashing
C. You deleted the stash manually before switching branches
D. You ran git stash apply instead of git stash
Solution
Step 1: Understand what git stash does
git stash saves changes temporarily but does not restore them automatically.
Step 2: Identify why changes are missing
If you switch branches without restoring stash using git stash pop or git stash apply, changes stay hidden in stash.
Final Answer:
You forgot to run git stash pop to restore changes -> Option A
Quick Check:
Stash saves but does not restore automatically [OK]
Hint: Stash saves; pop or apply restores [OK]
Common Mistakes:
Assuming stash auto-restores on branch switch
Confusing stash with commit
Deleting stash accidentally
5. You have uncommitted changes in your current branch but need to switch to another branch to fix a bug. Which sequence of commands correctly saves your work temporarily and restores it after fixing the bug?