views:

325

answers:

2

I'm a Git user trying to use Mercurial.

Here's what happened: I did a hg backout on a changeset I wanted to revert. That created a new head, so hg instructed me to merge (back to "default", I assume). After the merge, it told me I still had to commit. Then I noticed something I did wrong when resolving a conflict in the merge, and decided I wanted to have everything as before the hg backout, that is, I want this uncommited merge to go away. On Git this uncommited stuff would be in the index and I'd just do a git reset --hard HEAD to wipe it out but, from what I've read, the index doesn't exist on Mercurial. So how do I back out from this?

+1  A: 

hg update --clean

sblom
+4  A: 

If you've not yet commited, and it sounds like you haven't you can undo all the merge work with hg update --clean.

However, in newer mercurial's there's a handy command to re-merge a single file: hg resolve path/to/file.ext. From the hg help resolve:

The available actions are: ...

 4) discard your current attempt(s) at resolving conflicts and

restart the merge from scratch: "hg resolve file..." (or "-a" for all unresolved files)

Ry4an
Sorry, I'm still a bit confused: I ran `hg up -C`, but the "backed out" commit is still at the tip of my branch. I thought this was a "ghost branch" that got created with the `backout`, but running `hg branch` returns `default`, so I'm on the main branch after all?
obvio171
You can have two heads with the same branch, and that's what you've got. They're both named `default`. This is a very normal situation in mercurial and '`hg heads` is the command you use to discover/understand it.When you ran `hg backout` it "Commit the backed out changes as a new changeset" so that created a new changeset that won't go away w/o heroic effort. So now you have two heads both on the branch named default. After you `hg merge` (and commit it) you'll be back to one head on the branch named default.
Ry4an
Wow, didn't know this about the heads. Thanks for pointing that out :)
obvio171