- Have a theory about how to fix something
- Try it out
- Find out it was a stupid theory
- Realize that there is a kernel of learning in what you tried
- Realize that you don't want to throw away that kernel of learning quite yet
- But want to get the bad changes out of the way
- But there are some good uncommitted changes you don't want to throw away
- Ack, what should I do now?
- git checkout -b experiment-that-stunk
- git add -i (pick the one or two files that contain the changes you want to get rid of)
- git commit -m "tried to do something stupid, but it didn't work because ..."
- git checkout stuff-i-was-working-on
That is something that was NOT part of my experience before git.
Actually, I take that back, I did this once or twice before, but I wasted lots of time because I resisted give up on the experiment at the first sign of stupidity -- I subconciously knew it would be painful to save a whole patch, partially revert, hope I got it right, forget what I was doing, mess it up, revert all the way, re-apply the patch, repeat. So it took longer to abort the bad experiment because of the hesitation because of the perceived expense of partial revert.
I just realized this must be how "git stash" is implemented, and that it's definitely not a new idea.