Re: [RFC] undo and redo
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:04
On Wed, 24 Aug 2005, Carl Baldwin wrote:
Oops. I forgot to actually exit from the script if git-diff-files is non-empty. Also, looking at it now, I don't think keeping undo information in a stack is the right thing. But keeping more than just one would be good. Oh well, my first shot is never perfect. ;-)
I would actually argue that git checkout -b newbranch <undo-point> is the perfect undo. It leaves the old state in the old branch, and creates a new branch (and checks it out) with the state you want to revert to. The advantage is exactly that there is no "stack" of undo's: you can have multiple independent undo's pending, and you can continue development at any of them. And merge the results together. Of course, right now we don't have a "delete branch" command, but it's really as simple as rm .git/refs/heads/branchname (and eventually you may want to do a "git prune" to get rid of stale objects, but that's a separate issue). Linus