Bitbucket不支持原地子仓库。因此,Mercurial试图将您的每个存储库推送到同一位置,并在尝试将repo SubFolder2推送到SubFolder1 repo的远程副本时发生错误。
子存储库是用于多个项目之间共享的库,因此不属于任何一个主要存储库,而是有自己的空间。因此,您必须创建单独的远程存储库来容纳每个子存储库(库),并在.hgsub文件中引用该单独的远程路径。
例如,您的示例项目可以有三个托管在Bitbucket上的存储库。
https://bitbucket.org/bitbucketname/main_project
https://bitbucket.org/bitbucketname/library1
https://bitbucket.org/bitbucketname/library2
你希望你本地克隆的文件空间看起来像这样:
/MainFolder/
/MainFolder/SubFolder1
/MainFolder/SubFolder2
在您本地的main_project(主文件夹)中,将父存储库的默认路径设置为https://bitbucket.org/bitbucketname/main_project
即/MainFolder/.hg/hgrc
包含以下内容:
[paths]
default = https://bitbucket.org/bitbucketname/main_project
现在,在.hgsub文件中指定子仓库/库的远程路径。.hgsub条目的一般格式为:
local/path/to/subrepo = remote/path/to/matching/library
因此,您的 .hgsub 文件可能包含相对路径的本地和远程路径(相对于主仓库在本地或远程的位置):
SubFolder1 = ../library1
SubFolder2 = ../library2
或者使用相对本地路径连接到每个库的远程仓库的绝对路径:
SubFolder1 = https://bitbucket.org/bitbucketname/library1
SubFolder2 = https://bitbucket.org/bitbucketname/library2
或对于所有内容使用绝对路径:
/MainFolder/SubFolder1 = https://bitbucket.org/bitbucketname/library1
/MainFolder/SubFolder2 = https://bitbucket.org/bitbucketname/library2
现在,当你从本地主项目推送时,Mercurial 知道所有子仓库的确切位置(本地),以及如何将对每个库所做的更改推送到远程。
此外,假设你想将别人的库添加到你的项目中。那么你的 .hgsub 文件可能看起来像这样:
SubFolder1 = ../library1
SubFolder2 = ../library2
another_library = https://bitbucket.org/honkaboy/honkaboys_excellent_library
(https://(?:[^@]+@)?bitbucket\.org/[^/]+/[^/]+)/(.*) = \1-\2
由于替换后的UI不存在,这也没有起作用。有没有其他方法可以做到这一点,而不必将所有存储库重命名以匹配正则表达式。 另外,由于这是私有存储库,bitbucket会将用户名添加到格式化链接中,这会导致其他用户无法访问。 - samirjaiswal