Skip to content

Instantly share code, notes, and snippets.

@induratized
Created July 3, 2025 06:30
Show Gist options
  • Save induratized/25172e162c0e22094225707181473800 to your computer and use it in GitHub Desktop.
Save induratized/25172e162c0e22094225707181473800 to your computer and use it in GitHub Desktop.
git stash: how to apply unstaged file from stash

Thanks for the update. If git stash apply didn’t restore your staged changes, it’s very likely that:

🧠 Your staged changes are in the stash, but not restored by default

When you run:

git stash apply

…it only restores unstaged (working directory) changes by default — not the staged (index) part.

To bring back the staged changes you must apply with the index, like this:

git stash apply --index

This tells Git:

“Also restore the index (staged changes) that were saved in the stash.”


✅ Try This Now:

  1. List your stash entries to confirm one still exists:
git stash list

If there's a stash entry (e.g., stash@{0}), then:

  1. Inspect that stash to see what it holds:
git stash show -p --stat stash@{0}
  1. Now apply the stash including the staged changes:
git stash apply --index stash@{0}
  1. If you already applied the stash without --index, you can still drop and reapply it properly:
git stash pop --index stash@{0}

pop applies the stash and removes it from the stash list, unlike apply.


🚨 If You Already Popped or Dropped the Stash

If you've already run git stash pop or deleted the stash, you can try to recover it from reflog:

git reflog

Look for a line like:

stash@{0}: WIP on ...

or:

HEAD@{X}: stash: created ...

Then you can checkout or diff the stash commit:

git checkout <stash-commit-hash>

Or extract just the staged changes from it.


Let me know what you see in your git stash list and we can work through it precisely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment