Bird
0
0

You have the following stashes:

hard📝 Workflow Q8 of 15
Git - Stashing
You have the following stashes:
stash@{0}: WIP on feature A
stash@{1}: Bug fix
stash@{2}: Update README

Which command sequence will safely delete all stashes except the most recent one?
Agit stash clear && git stash apply stash@{0}
Bgit stash drop stash@{1} && git stash drop stash@{1}
Cgit stash drop stash@{2} && git stash drop stash@{1}
Dgit stash drop stash@{0} && git stash drop stash@{1}
Step-by-Step Solution
Solution:
  1. Step 1: Understand stash indexing

    Stashes are indexed from 0 (most recent) upwards.
  2. Step 2: Drop older stashes carefully

    Dropping stash@{1} removes 'Bug fix'. After this, 'Update README' moves to stash@{1}.
  3. Step 3: Drop the next older stash

    Dropping stash@{1} again removes 'Update README'. The most recent stash (stash@{0}) remains.
  4. Final Answer:

    git stash drop stash@{1} && git stash drop stash@{1} -> Option B
  5. Quick Check:

    Drop older stashes from higher index down [OK]
Quick Trick: Drop higher-index stashes first to keep recent [OK]
Common Mistakes:
  • Dropping stash@{0} first removes the most recent stash
  • Using git stash clear deletes all stashes
  • Dropping stashes without updating indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes