Mercurial/Kiln how can I get a deleted file without affecting my other files?
Asked Answered
U

2

6

I have a file that was deleted a few changesets ago. As you can imagine, the other files in my project have changed since then. How can I get back that file (it's actually 2 files) without reverting all the other source files?

Upswell answered 11/4, 2011 at 19:56 Comment(0)
A
9

Use hg revert for just that file:

hg revert -r REV path/to/deleted/file

From the help for hg revert

If a file has been deleted, it is restored. If the executable mode of a file was changed, it is reset.

If names are given, all files matching the names are reverted. If no arguments are given, no files are reverted.

Agle answered 11/4, 2011 at 20:8 Comment(1)
Thanks! Maybe I wasn't looking hard enough but I couldn't find that info anywhere.Upswell
I
0

Another approach to this is to use the Kiln website. You can search for a changeset by changeset id, or just use a date search, .e.g. date:2011-10-01..2011-10-31

That will then give you a list of changesets, click the one that will show the version of the code you want to recover, and then if you click the Browse files at [changeset id] link on the right hand side you will then get a list of the folders and files at that point in time.

You can then just add new files to your project and cut and paste the code back into those new files.

Admittedly this isn't as nice an approach for recovering a whole file, but it's handy if you only want to recover part of the code, or if someone has subsequently added a new file with the name of the old file.

Incubus answered 10/2, 2017 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.