Q:

How to undo a Time Machine restore?

I just attempted to restore a folder from TimeMachine.  I was expecting that TM would ask me where to put the restored folder (as it has done in the past, IIRC), but this time it didn't, and instead overwrote the folder1.
This is definitely not what I wanted.
Is it possible to undo the TM restore?
1Bizarrely enough, TM noticed that one subfolder already existed, and asked whether it should overwrite it, keep the latest version, or keep both.  What's bizarre about this is that only one subfolder was selected for such special treatment, out of dozens of subfolders for which it would have been equally applicable.

A:

Two things might work in your case:

Power off the Mac and hope an unerase utility can recover the files before they get overwritten (assuming the restore didn't write over the existing files on disk).
Delete the folder and try again from a different Time Machine snapshot.

