Mercurial 错误:存储库不相关
我刚刚开始使用 Mercurial,我在 Bitbucket 上有一个“中央”存储库,我将其克隆到一台计算机上并进行了更改、提交和推送。然后我从 Bitbucket 克隆到另一台已提交并推送的机器,这很好。然后我回到第一台机器,提交更改并尝试推送,但收到错误消息。我做错了什么?我应该先拉吗?如何解决错误并推送?任何帮助表示赞赏!
达伦.
I've just started with Mercurial, I have a 'central' repository on Bitbucket which I cloned onto one machine and made changes and committed and pushed. I then cloned from Bitbucket to another machine committed and pushed which was fine. I then came back to the first machine, made changes committed and attempted to push, but got the error message. What am I doing wrong? Should I have pulled first? How can I resolve the error and push? Any help is appreciated!
Darren.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当您在 Mercurial 存储库中进行第一次提交时,它会获取其身份。当您在 Bitbucket 上创建新存储库时,您将创建一个没有身份的空存储库。
当您将此存储库克隆到机器 A 并进行提交并将其推回时,您就为该存储库添加了品牌。如果您在从第一台计算机推送之前已在第二台计算机上克隆了存储库,那么您最终可能会遇到您所描述的情况。
请在无法推送的机器上运行
hg paths
。然后对它说要推送到的存储库进行单独的克隆。现在检查每个存储库中的第一个变更集如果初始变更集不同,那么您有两个不相关的存储库,正如我们在 Mercurial 中所说的那样。然后,您可以将无法推送的更改导出为补丁并将其导入到其他补丁中。
A Mercurial repository gets its identity when you make the first commit in it. When you create a new repository on Bitbucket, you create an empty repository with no identity.
When you clone this repository to machine A and make a commit and push it back, then you brand the repository. If you have cloned the repository on the second machine before pushing from the first, then you can end up in the situation you describe.
Please run
hg paths
on the machine where you cannot push. Then make a separate clone of the repository it says it will push to. Now examine the first changeset in each repository withIf the initial changesets are different, then you have two unrelated repositories, as we call it in Mercurial. You can then export the changes you cannot push as patches and import them in the other.
如果您非常确定推送路径正确,则可能值得从问题存储库中导出对补丁的更改,再次从 Bitbucket 克隆,然后将补丁导入到新存储库中。这要么正常工作,要么揭示错误/损坏的提交。
If you're pretty sure the push path is correct, it may be worth it to just export your changes to patches from the problem repo, clone again from Bitbucket and then import the patches into the new repo. This will either just work or reveal a bad/corrupted commit.
我想分享有关 Mercurial 内部结构的知识。
当存储库没有任何相同的修订时,它们不相关。
您可以在
mercurial/treediscovery.py
中找到相应的部分:base
是本地/远程存储库中公共部分的根列表。您始终可以通过以下方式了解存储库的不同之处:
您始终可以检查两者的根(在本地克隆两者之后):
如果上述命令的输出不共享 ID - 这些存储库是不相关的。由于散列属性,根不可能意外相等。您可能不会通过精心制作存储库来欺骗根检查,因为构建两个存储库看起来像这样(具有共同部分但根不同):
不可能,因为这意味着您反转 SHA-256,因为每个后续哈希都取决于先前的值。
有了这些信息,我相信任何开发人员都能够解决
错误:存储库不相关
。另请参阅 Mercurial 存储库标识
感谢您的关注,祝您好运!
I would like to share knowledge about Mercurial internals.
Repositories unrelated when they have no any same revisions.
Corresponding piece you can find in
mercurial/treediscovery.py
:base
is a list of roots of common parts in both local/remote repositories.You always may know how repositories are different by:
You always may checks roots of both (after cloning both locally):
if output from above commands doesn't share IDs - those repositories are unrelated. Due to hash properties it is very impossible that roots be equal accidentally. You may not trick roots checking by carefully crafting repositories because building two repositories looks like these (with common parts but different roots):
impossible because that mean you reverse SHA-256 as each subsequent hash depends on previous values.
Having this info I believe any Devs be able to troubleshoot
error: repository is unrelated
.See also Mercurial repository identification
Thanks for attention, good hacking!
当您尝试推送到您克隆的存储库以外的存储库时,您会收到此消息。如果您只是单独使用
hg Push
,请仔细检查推送的地址或默认
路径。要检查默认路径,可以使用 hg showconfig | grep ^paths\.default (或者只是
hg showconfig
并查找以paths.default=
开头的行)。You get this message when you try to push to a repository other than the one that you cloned. Double-check the address of the push, or the
default
path, if you're just usinghg push
by itself.To check the default path, you can use
hg showconfig | grep ^paths\.default
(or justhg showconfig
and look for the line that startspaths.default=
).