Git Subtree推送到Bitbucket或Github时

问题描述:

我有一个关于子树的问题。我有一个项目,我使用了一个使用子树机制添加的lib。在此之前,如果您知道自己在做什么,我总是会使用工作得很好的子模块。但我想尝试其他项目的子树。Git Subtree推送到Bitbucket或Github时

所以子树的工作也很好,但我的问题是,当我把我的回购推到github或bitbucket - 无所谓和其他人克隆回购...子树的远程信息丢失。

因此,如果我有很多通过子树添加的库,并且如果我失去了我的主人,那么我必须手动添加子树的所有远程...或者这里的正确工作流程是什么?

我总是想知道linux是如何管理的,因为我知道linux是从很多子树构建而成的。

非常感谢

这是Bitbucket的一个主要缺点(我假设github)。你的链接没有推到Bitbucket的原因是因为子树链接存储在仓库之外。

例如,在Sourcetree,子树链接存储在.git/sourcetreeconfig

<RepositoryCustomSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <AutoRefresh>true</AutoRefresh> 
    <AutoRefreshRemotes>true</AutoRefreshRemotes> 
    <DraftCommitMsg /> 
    <IncomingSavedCount>0</IncomingSavedCount> 
    <LastCheckedRemotes>2017-11-29T10:37:38.3041741-05:00</LastCheckedRemotes> 
    <LastUsedView>FileStatus</LastUsedView> 
    <LogBranchFilterIndex>0</LogBranchFilterIndex> 
    <OutgoingSavedCount>0</OutgoingSavedCount> 
    <SidebarExpandedItems> 
    <string>File Status</string> 
    <string>Branches</string> 
    <string>Remotes</string> 
    </SidebarExpandedItems> 
    <SidebarWidth>210</SidebarWidth> 
    <SubtreeLinks> 
    <SubtreeLink> 
     <SourcePathUrl>http://URL_TO_YOUR_BITBUCKET/scm/l20/00-0000-xx-eclipseutils.git</SourcePathUrl> 
     <Prefix>00-0000-xx-eclipseutils</Prefix> 
     <Refspec>master</Refspec> 
    </SubtreeLink> 
    </SubtreeLinks> 
</RepositoryCustomSettings> 

但是,此文件是由Sourcetree工具来维护,而不是实际存储在库本身。

潜在的解决方法是将文件.git/sourcetreeconfig存储在回购站(例如_sourcetreeconfig)中,并在签出存储库时将文件复制到.git。

这真的很遗憾,因为子树确实解决了Bitbucket的很多组织缺陷。

如果您想修改子树,您只需要远程信息。对于大多数用户来说,它将作为一个常规文件/目录,他们不需要特别注意。

您实际上需要远程跟踪信息的唯一实际用例是当您需要将子树更新为其各自远程回购的最新提交时。这样做的每个人都必须手动添加远程地址。