Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undo revert in git or tortoisegit

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?

like image 595
Justin Grant Avatar asked Dec 17 '22 20:12

Justin Grant


1 Answers

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.

like image 125
Justin Grant Avatar answered Jan 03 '23 17:01

Justin Grant