Accidentally, by using a GUI as opposed to CLI, I removed every file in a Mercurial project.
I recovered with Revert ok and lost some work, which as I have time machine I could easily get back. But is there a way of un-remove/undelete such files? Trawled through the manual and googled but cannot see anything. Any plugins?
I am probably answering my own question here but the files were gone from the directory and were not in the trash to recover so I am assuming Remove is irrevocable?
p.s. I know that hg forget
or hg remove -Af
will remove without deleting from the directory but my question has to do with the error I made as opposed to cool thinking the action through.
First go to Recycle Bin of your local machine. Your VS code deleted files is there in Recycle Bin. So, Right click on deleted files and select-> Restore option then your deleted files will be automatically restored in your VS code.
Click the Computer icon on your desktop to open it up. Navigate to the folder that used to contain the file or folder, right-click it, and then click Restore previous versions. If the folder was at the top level of a drive, for example R:\, right-click the drive and then click Restore previous versions.
First, use hg grep
to find the deleted file you wish to recover. The output of this command will show you the last revision for which the file was present, and the path to the deleted file. Second, run hg revert -r <revision number> <path to deleted file>
The deleted file will now be in your working copy, ready to be committed back into head.
Quote from comment:
I set up a repository, committed all, Removed and then committed again
If this is the case then you just need to update the working directory to the previous revision:
$ hg update -C -r-2
Note the negative revision number. If the files you deleted aren't in the previous revision, you can find them by using:
$ hg log -v
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With