I've taken a look at these previous questions already:
They don't exactly address a particular issue though - there are other changes in the index! When running the rebase command, git complains: Cannot rebase: You have unstaged changes.
Scenario:
The commit previous to the last one (do I refer to that as "2 HEADs ago"?) was a refactor commit. I currently have in the index many unstaged changes, but only some of which I want to add to the previous to last commit.
I'm imagining the way to do this would be to:
- stashall of my current changes
- rebase -ito the previous to last commit (changing index and moving Head, right?)
- load the stash into my index without changing Head (how?)
- use add -pandcommit --amendto selectively modify this old commit
- rebase --continueto finish (updates children, moves Head back to where I started, what happens to index?)
- then pop/clear the stash (index back to where I started).
Is this correct? If it is, how do I do step 3? If it isn't, what should I be doing instead?
Also, note that I'm still learning about git and am still not 100% sure I'm referencing things in git (Head, index, stash, etc) properly.
Solution:
For anyone else this may help, these are the steps I actually took:
- git stashall of my current changes
- git rebase -i <ID>to the parent of the previous to last commit, changing index and moving Head
- git stash applyload the stash into my index without changing Head- if you have conflicts, git reset HEAD <file>to unload files staging. Make sure staging is clear.
 
- if you have conflicts, 
- use add -pandcommit --amendto selectively stage changes and commit them
- git reset --hardto discard index so it matches Head
- git rebase --continueto finish. updates children, moves Head back to very start, but with changes- history is now forked into two versions. The other branch ends at the WIP previously stashed
 
- then pop the stash to bring index back to where I started. The other branch is also cleared.
 
     
     
     
     
    