undo revert in git or tortoisegit

Justin Grant picture Justin Grant · Nov 3, 2010 · Viewed 8.5k times · Source

Is there an easy way to undo a tortoisegit revert?

Here's more info: I just committed a large multi-file checkin, and right afterwards decided I instead wanted to commit a separate small checkin before the big one, to make it easier to amend that big checkin tomorrow.

So I brought up the log in tortoisegit, right-clicked on the last checkin, and chose "revert". This undid the changes and deleted a bunch of files in my working directory. What I really wanted was "reset" (roll back a checkin and leave my working directory as is), not revert (create an "undo checkin" in my working directory).

How can I undo my revert?

Answer

Justin Grant picture Justin Grant · Nov 3, 2010

After more Googling, I found the answer in this blog post: simply run the revert command again and it will undo your revert without littering your history with any extra commits. It's as if I'd never run revert in the first place.

The blog post only mentions this trick for regular (command-line) git, but the same thing works in tortoisegit. What's particularly nice is that other changes in my working directory are not blown away-- only the revert is undone.

I'm leaving the self-generated Q&A pair here, since it was kinda hard to find this answer-- hopefully will help someone else save time.