Pergunta

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?

Foi útil?

Solução

Just git reset to the point you wanted to, anyway. A revert is nothing special: it is just a normal commit which does the exact opposite of what another commit does. Since it is just a normal commit, it will be garbage collected just like the other commit(s) you originally wanted to get rid of.

Outras dicas

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.

I tried reverting a commit that I had previously reverted, and it did nothing. The result was "nothing to commit (working directory clean)".

What did work was cherry-picking the formerly reverted commit. That pulled in the changes that I had formerly reverted and did not otherwise alter my working directory.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top