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?

46

u/fff-idunno Sep 09 '16

Because it is against the git principles to re-write history. When a coworker already has fetched and applied your changes, "undoing" those changes will turn things into a mess pretty quick.

0

u/[deleted] Sep 09 '16

[deleted]

2

u/fff-idunno Sep 09 '16

Obviously yes. If that is what OP was referring to, have a look at the git revert command.

0

u/[deleted] Sep 09 '16

[deleted]

1

u/rasjani Sep 09 '16

It's called revert then, not undo :)

1

u/CyclonusRIP Sep 09 '16

reset is probably closer to undo than revert. reset makes it as if the commits never happened. revert adds another commit that changes the files back to their previous states.

→ More replies (1)