I have a local repository and I want to get the latest changes from a remote repository. I know i can clone but clone only works on new directories. I know i can delete the local repository and then clone but i want to know how do it the Mercurial way if there is one.
EDIT: hg pull -u doesn’t work if there are conflicts. I don’t want to resolve conflicts I just want to get a fresh copy of the remote repo regardless of local changes.
ANSWER: Short answer: Maybe it can be done (see answer below) but re-clone is easier.
Long answer: if you want to get the latest from a remote and disregard your local changes and commits then you’ll have to clone to a new local repository or remove the local repository and clone another one. This is because if you have conflicting changes then hg will force you to resolve them manually.
Which is OK but I just wanted to know if it can be done without removing my local repo.
Looks like you are looking for
hg strip, which isn’t part of the Mercurial core. It’s available through the MqExtension. You can enable it by adding the following in your .hgrc or Mercurial.ini file (https://www.mercurial-scm.org/wiki/MqExtension)Then you will be able to:
This will remove your changesets to the point where you shouldn’t have any merge conflicts. This will impact the branch history though. But then again, that’s not so bad, if you keep them any good future changeset will have an ancestor that you decided to trash.
If you are just trying something out, you’re better of doing it in a separate branch which is easy to close and abandon later.
If you really are looking to keep the bad changeset you can pass in configuration option to the merge command like this
This is documented in Mercurial tips and tricks.