n179911 n179911 - 3 months ago 13
Git Question

Why does 'git stash apply' stage my changes?

I make a change and then I

git stash
and then I
git stash apply

My question is
1. why after I
git stash apply
, my change becomes 'staged'? i.e. I won't see anything if I do
git diff
, I only see my difference if I do
git diff --cached

  1. Is there anyway to 'unstage' my changes staged by
    git stash apply

  2. Is there any git command basically let me to 'make a backup of my change, reset it to the HEAD and the copy my backup back'? I thought
    git stash
    and then
    git stash apply
    is that command, but some how it 'staged' all my changes? Is there any equivalent which let me
    git stash apply
    without the staged my changes part?

Thank you.


If you find that your changes are unexpectedly staged, do:

git reset HEAD

I usually only see this if there is a conflict when applying the stashed changes. You will want to check to see whether this is the case before doing the git reset.

The git stash command is the most appropriate command for your use case. I use it all the time for exactly this purpose.