-->

How to see a mercurial difference

2020-07-27 04:30发布

问题:

abort: push creates new remote heads!
(did you forget to merge? use push -f to force)

Is there a way to see which differences I'm handling? I'm tempted to do a push -f and first want to see what I'm overwriting. Thanks!

回答1:

Don't execute push -f, ever :) It will most likely fail but still, don't do it. I learned that the hard way.

The error happens because some has already pushed something to the master repository. What you need to do is pull changes before pushing them. To see what will you get, run hg in or hg incoming (in is an alias of incoming), and afterwards run hg pull -u. See this page for more information on what else you can do.



回答2:

To see the differences between your local and the remote repository, run hg incoming. Then you can decide if you want to

  1. push your changes anyway and create a new head on the remote side (using push -f),
  2. or if it is better to pull the remote changes first, merge them locally and push the
    merged changes.

The latter one usually is preferable, it depends on how you collaborate with the other developers. Note that if you do a hg pull first, your local changes aren't touched, so you can inspect the remote changes side-by-side with your local ones and you can still decide not to merge and do a hg push -f anyway.



回答3:

You need to do a pull first. Then a merge. Then a push.

push -f may be dangerous.

To answer your question you can see changes that you made:

hg status

and

hg diff

in your local repository.

hg incoming

shows any changes in the remote repository that you have not yet pulled.



标签: mercurial