简体   繁体   English

Mercurial中的分支和远程磁头

[英]Branching and remote heads in Mercurial

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? 您如何在不同的分支机构上远程工作并推送到一个存储库?

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). 使用hg push --new-branch强制它(或版本1.6之前的-f )。

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. 使用命名分支单独克隆有助于:新克隆将始终更新到默认分支的头部,然后人们可以根据需要更新到另一个分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM