How to undo a pull

Giorgos Keramidas keramida at ceid.upatras.gr
Fri Aug 31 05:36:08 CDT 2007


On 2007-08-31 12:54, "Imbeault, Jean-Christian" <jeanchristian.imbeault at lehman.com> wrote:
>
> I've just done a pull and realised that I don't want the change. How
> do I undo the pull?
>
> I'm trying to push some changes to a central repository but I'm
> getting a 'creates new branches!' error and I'm guessing this is
> because of the bad pull?

Please copy/paste the exact error message when asking for help.

What you are seeing is probably a "pull" which would create more heads
in a remote repository.  This is normal with Mercurial, and not the
result of a bad pull.

Let's assume that you "cloned" the remote repository when its history
was something like this:


  [0:1b0bd779] ---> [1:a13b50d2]


When you cloned your copy, you committed change [2:480ef2be] locally,
and your history became:


  [0:1b0bd779] ---> [1:a13b50d2] ---> [2:480ef2be]


At the same time, someone else cloned the initial remote repository.
They still got the initial history:


  [0:1b0bd779] ---> [1:a13b50d2]


Then they committed in their local copy, and pushed to the common remote
repository their own stuff:


  [0:1b0bd779] ---> [1:a13b50d2] ---> [2:c42360ce]


Now, if you push your _own_ local changes, the history of the remote
tree will become:


  [0:1b0bd779] ---> [1:a13b50d2] ---> [2:c42360ce]
                           \
                            +-------> [3:480ef2be]


This is why Mercurial warns you about "creating remote heads".

You basically have two options:

  1. Ignore the remote heads and use "hg push -f".  Then people will be
     able to pull your changes from the common repository, and if they
     feel like it merge the two heads.

  2. Pull from the remote repository (like you did), and get the two
     heads locally.  Merge the two heads in your own workspace, and
     commit the merge changeset.  This would create a history like this:


  [0:1b0bd779] ---> [1:a13b50d2] ---> [2:480ef2be] ---> [4:c661e1ad]
                           \                               /
                            +-------> [3:c42360ce] -------+


Then you can push the merge changeset along with your local changes,
and Mercurial won't complain that you are creating more heads.



More information about the Mercurial mailing list