views:

42

answers:

3

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.

A: 

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
pyfunc
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
@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.
pyfunc
Edited original post. Give it a look.
Gabriel A. Zorrilla
+2  A: 

Found a solution:

hg revert file -r15 //(reverts file to revision 15).
Gabriel A. Zorrilla
@Gabriel A. Zorrilla: That should do :). I just saw your edit to question
pyfunc
@Gabriel A. Zorrilla: Did you try hg update file -r15 ?
pyfunc
Yes, got this:abort: please specify just one revision
Gabriel A. Zorrilla
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).
Nick Pierpoint
A: 

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

philosodad