I am aware of Mercurial for Beginners: The Definitive Practical Guide and answers like Mercurial merge branches? (abort: push creates new remote branches)
Here I've inadvertently created a situation where Mercurial wants to create a new remote head. What's the best way to undo this, and leave little or no trace of this mistake on the remote side?
###> hg push
pushing to http://example.com
searching for changes
abort: push creates new remote heads on branch 'default'!
(did you forget to merge? use push -f to force)
###> hg revert --all -r tip
###> hg update -C
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
###> hg incoming
comparing with http://example.com
searching for changes
no changes found
###> hg summary
parent: 488:e3db024fe901 tip
Misc.
branch: default
commit: (clean)
update: 6 new changesets, 2 branch heads (merge)
###> hg pull
pulling from http://example.com
searching for changes
no changes found
###> hg glog
@ changeset: 488:e3db024fe901
| tag: tip
| summary: Misc.
|
o changeset: 487:b207579b9d41
| parent: 480:ce775708800c
| summary: Misc.
|
| o changeset: 486:59a7a5b34c7f
| | user: other
| | summary: fixes
| |
| o changeset: 485:b28264333e18
| | user: other
| | summary: binary
If I merge, it sort of seems OK:
hg merge
abort: outstanding uncommitted merges
But hg diff
shows all sorts of changes I did not make. I'm willing to re-apply my changes... how can I bring this all back to a single tip, abandoning all local changes?
It looks like when you've done an hg merge
, you haven't committed the resulting changeset.
When you merge in another branch (in your case you may need to specify hg merge 486
to merge in the other users changes), it merges that branch into your working directory. You then need to check that all conflicts are resolved (if there are any) by using a merge tool, or manually editing the files (and then running hg resolve
on any conflicts). Once this is done you need to hg commit
your new, merged changeset.
This would explain why hg diff
gives you lots of changes you didn't make -- they're changes made on the other branch, that you have yet to commit. If you run hg summary
or hg parents
in your working directory, you should see two parents listed: 486
and 488
. You should hg commit
this working directory, creating a new merged 489
.
If you want to undo the current merge and start again, you're correct in trying to run hg update -C
, which will set your working directory back to its original (unmerged) state.
If you want to get rid of your changes (487
and 488
- you state you don't mind re-applying your changes), the easiest option without resorting to extensions is simply to re-clone the repository and continue your work from there.
To get rid of changes (ex 487 and 488): If you feel (as I do) that re-cloning the repository, as recommended above and even officially recommended here is ridiculous, then you should get MqExtension
Once Mq is enabled, you can easily remove changes you don't want:
hg strip 487
hg strip 488
I did not do merge, but suddenly I am viewing the message the op has posted. When I do a hg pull, in the command line it shows abort !repository default not found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With