BitBucket - 创建仓库和子模块

8
我正在使用 bitbucket 网页界面,并创建了一个名为“Test_Project”的新项目。在该项目中,我可以使用创建仓库选项来创建一个名为'Module1'的新仓库。
现在我想在bitbucket项目 - Test_Project 中创建以下仓库层次结构:
Test_Project (Bitbucket 项目)
  • Web (Repository 1)

     Module1 (Sub-Repository/Sub-module 1)
     Module2 (Sub-Repository/Sub-module 2)
     Module3 (Sub-Repository/Sub-module 3)
    
  • Mobile (Repository 2)

     Module1 (Sub-Repository/Sub-module 1)
     Module2 (Sub-Repository/Sub-module 2)
     Module3 (Sub-Repository/Sub-module 3)
    
  • Archive (Repository 3)

     Module1 (Sub-Repository/Sub-module 1)
     Module2 (Sub-Repository/Sub-module 2)
     Module3 (Sub-Repository/Sub-module 3)
    
  • Project Documents (Repository 4)

    And so on..

我想要将本地项目添加到相应的 Bitbucket 子仓库中。

请问有人可以指导如何在新的 Bitbucket 仓库中创建子仓库/子模块吗?

2个回答

15

您只需要在根目录中添加子模块文件夹即可。

git submodule add <url>

现在当你克隆这个项目时,你只需要初始化并更新子模块即可。
git submodule init
git submodule update

Git 1.8.2新增了一个名为--remote的选项

git submodule update --remote --merge

该命令将从上游获取每个子模块的最新更改,将其合并并检出子模块的最新修订版。正如文档所述:

--remote

此选项仅适用于更新命令。不使用超级项目记录的SHA-1来更新子模块,而是使用子模块的远程跟踪分支的状态。

这相当于在每个子模块中运行 git pull 命令。


Git 2.8 更新

Parallel fetches of submodules

Using git submodules, one Git repository can include other Git repositories as subdirectories1. This can be a useful way to include libraries or other external dependencies into your main project. The top-level repository specifies which submodules it wants to include, and which version of each submodule.

When you fetch into the top-level repository, you typically want to fetch into the submodule repositories as well:

git fetch --recurse-submodules

If you have a lot of submodules, all of these fetches can be time-consuming; git fetch is essentially run in each submodule in turn.

But now you can speed things up by fetching from multiple submodules in parallel. For example,

git fetch --recurse-submodules --jobs=4

嗨,我可以使用 git submodule add <url> 将子模块文件夹添加到本地根文件夹中。 现在,我想将包含子模块的本地根文件夹推送到 Bitbucket 服务器上,但我无法做到这一点。在推送时,它会显示以下消息:-$ git push -u origin --all No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'. Everything up-to-date请指导如何在 Bitbucket 中创建和推送子存储库/子模块到新存储库中。 - Jatin

-7

现在,我能够创建具有子仓库/子文件夹的Bitbucket存储库结构。

请按照以下步骤操作:

  1. 在Bitbucket项目中创建一个新存储库。
  2. 要与您的新存储库交互,您需要使用git客户端将此存储库克隆到本地计算机上。我正在使用'SourceTree'作为GIT客户端(另一个Atlassian产品,与Bitbucket集成良好,您可以在Bitbucket中使用“Clone To SourceTree”按钮使事情更容易)。
  3. 一旦您拥有本地存储库,请将您的项目复制/移动到其中,并使用您选择的工具添加/提交文件并将其推送到bitbucket。

谢谢,

Jatin


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接