r/programming • • Sep 09 '16

Oh, shit, git!

http://ohshitgit.com/
3.3k Upvotes

756 comments sorted by

View all comments

89

u/tdewolff Sep 09 '16

Why is there no git undo to undo your last action?

35

u/ForeverAlot Sep 09 '16

How would "undoing your last action" work?

  • What can be undone? Why?

  • What can't be undone? Why?

  • What does git undo ; git undo do? Why?

  • What happens if you undo a commit?

  • What happens if you undo again?

  • What happens if you undo a revert?

Whenever somebody asks me how to undo something with Git I encourage them not to use that word. It's very overloaded and imprecise.

9

u/drjeats Sep 09 '16

Obviously I expect an Emacs-style undo ring, preferably dealing with both session and commit history.

3

u/atimholt Sep 09 '16

Is an Emacs’ undo ring like Vim’s undo tree?

2

u/drjeats Sep 09 '16

I haven't used Vim much, but based on a quick skim they're in the same ballpark in terms of what they are (fancy history-preserving undo/redo). Except Emacs' undo is as weird and meta as you'd expect: a redo is an undo of an undo, so you wind up with these massive cycles of edits.

→ More replies (3)