How do you tell git to stash the index only?
Simplest way is to leave off that change right now, make your new commit, then create a second commit with just that change you want to use to amend and then use git rebase -i
to squash it with the original HEAD.
An alternative would be to make your commit, tag it, roll back with git reset HEAD^
, add that one change and amend HEAD, then cherry-pick your tagged commit.
Why not cheat?
git stash --keep-index
to get everything out of there that's not in the index currently. Then,
git stash
to get a stash with just the stuff that's staged.
git stash pop
the first stash, add your changes. Then,
git commit --amend ...
git reset --hard
to clean up the working tree and then
git stash pop --index
to get your index changes back.
The closest thing I've found is git stash --patch
. It walks you through each of the changes to working tree and index letting you choose what to stash.
http://www.kernel.org/pub/software/scm/git/docs/git-stash.html