8

I made a mistake and removed a file. I'd like to go back to my previous commit! I tried with revert and backout with had no luck...

Any tip?

Edit: I did exactly this:

 hg forget file hg commit -m "Blah" hg push 

The revision number of this last push is 17.

Now file is not tracked anymore. I'd like to get it back to revision 15 (not the inmediate previous rev, but one extra step back) as i do not want to keep working on the file in rev 16.

3 Answers 3

9

Found a solution:

 hg revert file -r15 //(reverts file to revision 15). 
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, got this: abort: please specify just one revision
This will revert your working copy to r15, but you still have an issue because you've pushed the deleted file to the parent. You can re-introduce the file and push the re-introduced file as described or you can edit history in the parent repository (if no one has subsequently pulled).
0

If you have committed then you could update to previous version. If the file is version controlled, it is not going to go away. Thats what version control are for.

hg update -r "what is previous rev" 

If you have removed a file and had not committed, then simply do the update and it will restore the file.

hg update 

[edit: based on edited question]

hg revert file -r 15 hg update file -r 15 

3 Comments

The modification was commited and pushed with a "R" in a file, resulting lack of tracking. But i do not want to push back my actual file located in the hardrive because has modifications i do not want to push into the server. So, i must go back to a total, previous version. I dont know if I'm being clear enough. Thanks for your help.
@Gabriel A. Zorrilla : give us a more detailed account of the issue. it is not very clear yet. Even if the file is marked 'R', previous versions should have it and you should be able to revert to it.
Edited original post. Give it a look.
0

Try pulling version 15 and hg pull -r and then adding the file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.