I'm using Mercurial and am a bit of a newbie. I just committed a change to my repo successfully, then ran hg pull
and hg update
successfully - no merges and no conflicts showed up.
Then I tried to push to the remote repo, and got the dreaded: abort: push creates new remote heads!
hg glog
shows the following:
@ changeset: 576:c4c58970f141
| tag: tip
| user: me
| parent: 566:70e287df5439
|
| o changeset: 575:7ae70ddd2b6e
| | branch: mongo
| |
| o changeset: 574:904da90475ef
| | branch: mongo
| |
| o changeset: 567:cad7a006965b
|/ branch: mongo
|
o changeset: 566:70e287df5439
| user: me
|
Looks like someone has created a new branch in the repo, which is fine: I just want to push my changes to the default branch, but I don't know how.
How can I push changeset 576? Do I need to specify that it's to branch default?
Mercurial's push command has the -r
option to limit the push to changes up to a given revision:
If -r/--rev is used, the specified revision and all its ancestors will be pushed to the remote repository.
This implicates that you also limit the branch you're going to push. To push all changes up to the tip of the default branch, you could run:
$ hg push -r default
This will ignore your mongo branch. Instead of branch names, you can also use specific revisions:
$ hg push -r 576
Obviously, as long as revision 576 is the tip of the default branch, both commands have the same effect.
On a side note, there is an often handy shortcut to push only the parent revision of the currently checked out working copy, using a period as the revision specifier:
$ hg push -r .
Something else is going on because a remote branch like mongo
doesn't cause a multiple head abort, only multiple heads on the same branch do. [Update: Actually, you do get a remote branch abort, analogous to a remote head abort, unless you have Push new branch
checked in the Synchronize menu of your TortoiseHg as I did.]
No matter the cause, the proper procedure is to commit to your local repo (which you've done), then pull the remote changes, merge them with yours, commit the result and, finally, push the merged changes to the repo.
There is an extension called fetch
which helps consolidate this process into a single step. You can learn more about it here.
Don't just force the push to the remote repo! This is just avoiding responsibility for the merge and may even break things, such as a build system which relies on having all changes in an unbranched line. At the least you will confuse or irritate those you are working with. Unless that is your intention, in which case, full steam ahead. :)
You really need to read some of the basics about collaboration before you start doing it. Start here.
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