How to "push" manually?

Peter Hosey boredzo at gmail.com
Sun Apr 5 17:49:11 CDT 2009


On Apr 05, 2009, at 15:28:52, skip at pobox.com wrote:
> It seems either the first or third one should work but doesn't for  
> some mystifying reason.  What is a "remote head"?  I don't think I  
> forgot to merge.  Was I supposed to merge something?

Apparently so. You have one or more heads in your local repository  
that the remote repository doesn't. If you pushed everything, the  
remote repository would have heads that it previously didn't. That's  
“creating remote heads”.

Ordinarily, you're supposed to merge these heads back into a single  
line, then push. Alternatively (with the rebase extension), you can  
rebase the divergent line of history onto the one you consider  
primary, assuming you haven't previously pushed any part of that line.  
If you really do want to create remote heads, you can use push -f.

The reason you want a single line is that each of your multiple lines  
has changes that the other doesn't. Merging brings this down to a  
single line of history with everything. You can always revive a line  
of history after merging it into another, if you decide you really  
want to. (That would be “creating an unnamed branch”; it's easier  
to use named branches instead, since you can refer to each branch by  
name.)

> Is there not a simple Mercurial cheat sheet somewhere?

What good is knowing commands without understanding the concepts  
behind them?

I imagine such a cheat sheet would tell you “to push despite remote  
heads, use push -f” (…like push itself did). If you did this every  
time, you would eventually have many remote heads representing many  
divergent lines of history. You might update to one and wonder why  
changes from another are missing. You might even then blame Mercurial,  
but Mercurial merely did what you told it to do.

Here's what happened:

1. You started from revision X.
2. You committed one or more times.
3. For one reason or another, you updated back to revision X.
4. You then committed something else. This is where you created your  
second head.

Note that head #1 and head #2 both descend from revision X, and are  
the heads of separate lines of history since X. Graphically:

         o #1
         |
         |
o #2    o
|       |
|       |
o       o
|       |
|       |
o       o
  \     /
   \   /
    \ /
     o X

(The glog command from the graphlog extension will give you a similar  
graph. It's unbelievably handy.)

So, again, your choices:

1. Leave this alone: You meant to do this (either at the time, or  
retroactively starting now). Force the push, since you really do want  
this second, separate line of history.
2. Cover your tracks: Rebase the #2 line (starting from its first  
commit after X) onto #1. Requires that you have not pushed (and no-one  
has pulled) any part of the #2 line. Also requires that you turn on  
the rebase extension.
3. Merge #2 into #1 (or vice versa).




More information about the Mercurial mailing list