Suppose two set of changes are made in a project versioned by git. One set is staged and the other is not.
I would like to recheck staged changes by running my project a
I found the marked answer did not work for me since I needed something which truly stashed only my unstaged changes. The marked answer, git stash --keep-index
, stashes both the staged and unstaged changes. The --keep-index
part merely leaves the index intact on the working copy as well. That works for OP, but only because he asked a slightly different question than he actually wanted the answer for.
The only true way I've found to stash unstaged changes is to not use the stash at all:
git diff > unstaged.diff
git apply -R unstaged.diff
git checkout -- .
will also work instead of apply -R
.
Work work work...
git apply unstaged.diff
rm unstaged.diff