Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I git reset --hard HEAD on Mercurial?

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?

like image 268
agentofuser Avatar asked Apr 20 '10 04:04

agentofuser


People also ask

How do you reset a hard head?

To hard reset files to HEAD on Git, use the “git reset” command with the “–hard” option and specify the HEAD. The purpose of the “git reset” command is to move the current HEAD to the commit specified (in this case, the HEAD itself, one commit before HEAD and so on).

What does the command git reset hard head 2?

HEAD reveals the new branch or commit, meaning that what git reset-hard HEAD can do is throw away all the changes you have that are not committed. The git command "git reset" overwrites (HEAD / Index (also known as a staging area) / working directory) in a particular order: Transfer whatever HEAD branch points to.

What does git reset head mean?

The git reset HEAD~2 command moves the current branch backward by two commits, effectively removing the two snapshots we just created from the project history. Remember that this kind of reset should only be used on unpublished commits.

What does the command git reset soft head 3 do?

git reset changes where the current branch is pointing to ( HEAD ). HEAD is a pointer or a reference to the last commit in the current branch. HEAD~3 would mean behind 3 commits from HEAD . Assuming HEAD is pointing to C3 and the index(stage) matches to C3 .


2 Answers

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)

like image 66
Ry4an Brase Avatar answered Nov 08 '22 17:11

Ry4an Brase


This is close:

hg update --clean

like image 29
sblom Avatar answered Nov 08 '22 18:11

sblom