Monday, May 16, 2011

Mercurial push fails with message - abort: push creates new remote heads on branch 'XXXX'!


When trying to push changes to the mercurial server from your local mercurial, you may get this error message:

abort: push creates new remote heads on branch 'XXXX'!
hint: did you forget to merge? use push -f to force
[command returned code 255 Mon Mar 16 15:53:41 2011]


This is applicable to Tortoise Hg 2.0.2

Solution
This type of message generally occurs in following scenario:

You clone the repository.
Didn’t update it for sometime, during which time another developer committed and pushed changes to repository.
You did not pull changesets
You updated your files
You committed the files to your local repository
You are trying to push the changes to the central repository.
You get the error.

Reason being that there is a different revision number than when you last pulled from the central server on your local machine.
You should always, always pull from the central server and then only try to push back your changes.

Steps to fix it
Do not forcefully push as suggested by the error message.

  • ·         Start the Tortoise Workbench
  • ·         From the menu Go to, Repository -> Terminal
  • ·         On the terminal command prompt type
hg merge

  • ·         This will merge  your local changes and align them to that of the central server.
  • ·         Close the command prompt window
  • ·         Now go to windows explorer and select the repository right click on it and do a “Hg Commit”.
  • ·         Now go to Hg Workbench do a push and it should work fine.


1 comment: