Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I started down a new branch of development and decided that some files needed to go.

Several commits later I realise that a certain decision was wrong and I need a couple of the files back.

My initial thought of how to get the files back is to just take copies from the other branch and commit them to the head of the new branch, but I worry that this means that the files won't be associated with their old history.

Is there a way to do this that keeps the history intact?

I'm using mercurial version 1.5.2

share|improve this question
up vote 5 down vote accepted

I found this solution on another website, but I can't find where.

The answer is to revert the files that were deleted individually:

hg revert -rxxx filename

where xxx is the revision number of before the delete.

Then commit them back in. The history is preserved!

share|improve this answer
This gives exactly the same result as copying the file. – tonfa Apr 14 '11 at 20:39
@tonfa: thanks, I guess I was overthinking things :D – Matt Ellen Apr 14 '11 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .