Branching and remote heads in Mercurial

落花浮王杯 提交于 2019-12-03 08:37:58

问题


I created a new branch using this command:

hg branch new_branch

After the first commit to the new branch, the default branch becomes inactive. If this is pushed the central repository will have only one head which belongs to the new branch.

When my colleague pushes his commits on the default branch, he will get this error:

pushing to ssh://...
searching for changes
abort: push creates new remote heads!
(did you forget to merge? use push -f to force)

Is there anything bad about forcing the push? Why are remote heads bad?

How do you work remotely on separate branches and push to one repository?


回答1:


Remote heads are bad because you’re basically pushing the effort of merging onto another person. This message is there to prevent people from accidentally introducing remote heads, telling them to merge first before pushing.

In this case though, you have created a named branch, meaning you intentionally introduce and share a new head, and you can discard the warning as informational. Use hg push --new-branch to force it (or -f before version 1.6).




回答2:


In addition to pushing the job of merging to someone else, remote heads are also bad since they can cause confusion. People who make a new clone wont know which head to start from if there are several. To make things worse: a new clone will be updated to the newest head on the default branch, and this head changes from one moment to another when people push changes to the different heads.

Using named branches or separate clones help here: a new clone will always update to the head of the default branch and people can then update to another branch as needed.



来源:https://stackoverflow.com/questions/2591276/branching-and-remote-heads-in-mercurial

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!