Mecurial repository files lost - How do I recreate and push to the original cloned repo?

76 Views Asked by At

I just lost my .hg* files for my repository after a migration and I have made a bunch of unpushed changes to some code.

I need to Init a new repository and then push my changes to an existing remote repository. Do I just need to init a new repo and then specify the remote repo in the hgrc and push? Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

If you remember the changeset you had in your original repo as its working parent (let's call it A), then you can do this:

$ hg clone http://server/upstream newrepo
$ cd newrepo
$ hg up A

Then copy the working copy of the original repo to the new repo (with an additional precaution of deleting all files from the new repo if you renamed / deleted anything in the old repo). Afterwards, commit and push from the new repo:

$ hg commit
$ hg push

If the upstream repo has anything on top of A, rebase or merge before pushing.