Bird
0
0

You have multiple stashes and want to remove all except the most recent one. Which sequence of commands achieves this safely?

hard📝 Workflow Q15 of 15
Git - Stashing
You have multiple stashes and want to remove all except the most recent one. Which sequence of commands achieves this safely?
ARun <code>git stash drop stash@{1}</code> repeatedly for all except stash@{0}
BRun <code>git stash clear</code> then create a new stash for the most recent changes
CRun <code>git stash pop</code> to apply and remove all stashes except the latest
DRun <code>git stash drop stash@{0}</code> to remove the latest stash only
Step-by-Step Solution
Solution:
  1. Step 1: Understand stash indexing and removal

    Stashes are indexed from 0 (most recent) upwards. To keep the latest, remove others starting from index 1.
  2. Step 2: Use git stash drop stash@{1} repeatedly

    Dropping stash@{1} repeatedly removes older stashes safely without affecting the latest stash@{0}.
  3. Final Answer:

    Run git stash drop stash@{1} repeatedly for all except stash@{0} -> Option A
  4. Quick Check:

    Drop specific stashes to keep latest safe [OK]
Quick Trick: Drop stashes from index 1 up to keep latest [OK]
Common Mistakes:
  • Using clear which deletes all stashes
  • Using pop which applies and removes only one stash
  • Dropping stash@{0} which removes the latest stash

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes