Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save chicao/07ef086e2ab01c8c219d379218e8734f to your computer and use it in GitHub Desktop.

Select an option

Save chicao/07ef086e2ab01c8c219d379218e8734f to your computer and use it in GitHub Desktop.
[MERCURIAL] : Push problems due to conflicts and multiheads
It's not rare to mercurial 'push' commands return the annoying abort message:
$ hg push --rev <WORK_BRANCH>
pushing to <REPO URL>
searching for changes
abort: push creates new remote head <HEAD ID> on branch <WORK_BRANCH>!
Usually this means that you didn't updated your local repository with other programmers code.
The usual fix is to update your main branch by pulling changes, merge your local repository with remote changes,
commit the merge and then push to the remote repo:
$ hg pull -u
If a conflict happens, you must solve it with a merging tool (KDE's kompare, vim-diff, etc...) and after solving
the problem, mark the file as resolved:
$ hg resolve -m <FILE NAME>
And then complete the merge and repush your modifications:
$ hg merge <MAIN BRANCH>
$ hg commit -m "Merged <MAIN_BRANCH> remote changes"
$ hg push --rev <WORK_BRANCH>
However, if everythings seems OK, no merge conflicts, a successful merge was done, no uncommited changes were left
and you STILL have the annoying message, you must check your <WORK_BRANCH> for head conflicts:
$ hg heads <WORK_BRANCH>
changeset: 1111:ABCDEF123456
parent: 0000:ABCDEF123456
user: Jane Doe <[email protected]>
date: Sun Jul 31 00:00:00 2099 -0000
summary: A commit message
changeset: 2222:ABCDEF123456
parent: 0000:ABCDEF123456
user: Jane Doe <[email protected]>
date: Sun Jul 31 00:00:00 2099 -0000
summary: Another commit message, from the last modifications
You have two heads in your local branch. If you don't have no file differences indicated
with your branch status command, you can revert the changes.
$ hg revert -a
And then you can commit the remote changes to mark the revert and pull to your revision.
$ hg commit -m "Merged after revert"
$ hg heads <WORK_BRANCH>
changeset: 2222:ABCDEF123456
parent: 0000:ABCDEF123456
user: Jane Doe <[email protected]>
date: Sun Jul 31 00:00:00 2099 -0000
summary: Another commit message, from the last modifications
$ hg push --rev <WORK_BRANCH>
pushing to <REPO URL>
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added Z changesets with Y changes to X files
remote:
Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment