Reverting an uncommitted revert
- From
Joshua Jensen <jjensen@workspacewhiz.com>
- Date
- May 20, 2009, 02:34 UTC
- Message-ID
- <4A136C40.6020808@workspacewhiz.com>
I had an interesting experience the other day I'd like to share. It is a story of my stupidity plus a bug in the latest version of the Mac OS X 'git gui'.
I had spent several evenings working on a piece of source code. It was basically working, but I hadn't committed anything yet. Yes, I know I should have made a branch and performed incremental commits, but I didn't. This is why I was stupid.
Because of a busy week, it was many days before I could get back to what I was working on. By then, I had forgotten what I was doing, and so I pulled up the handy 'git gui' to show me my diffs.
'git gui' showed me a single whitespace change in the diff. The scroll bar extended from top to bottom in the diff window and wouldn't move. (This is the bug, which is easily reproducible.) I thought, "Gee, that's weird. I thought I'd made more changes." Not wanting the silly whitespace change, I chose Commit->Revert Changes from the menu.
A couple hours later, I was pulling my hair out trying to find the change that I knew, deep down, I had reverted.
I also knew there was no support for putting a reverted change in the reflog, but hey, the reflog has saved me before. I looked. It wasn't there.
So here's the idea: What if Git, upon a revert change (or git reset --hard HEAD), "committed" the changes to be reverted and then did the revert with a 'git reset --hard HEAD^'? The reverted files would be disconnected from a branch, but they would be available in the reflog to retrieve.
Or do I just not 'get it'?
Thanks!
Josh