如何将存储库添加到antoher,作为GitHub上的文件夹

问题描述 投票:0回答:1

我有一个具有“正常行为”的存储库A。在该仓库中,我有readme.md,About.md,带有其他文件的某些文件夹等。我想知道的是为我的家庭辅助自动化添加一个单独的文件夹,该文件夹在Im在Raspberry Pi上运行(这将是存储库B)

我已成功添加到本地,并通过Pi的控制台通过github与我的github连接,但是它无法按预期方式执行“推”命令,因为我没有执行“拉”,但是我确实不需要这些文件Pi,它将搞乱我的配置。

我想拥有类似的结构

Project (Repository A)
 - Readme.md
 - Folder1
   - SomeFile.txt
 - RepositoryB Folder (in this folder will be pushed form my Pi files and config)

Should I just use a fork on repositoryB which will be a separate repo?
git github
1个回答
0
投票

您可以通过git submodule add https://github.com/<name-of-repo B>将存储库B作为存储库A的子模块。通过这种方法,您可以独立地将更改推/拉到存储库A和存储库B。

克隆包含子模块的存储库时,之后必须执行git submodule update --init --recursive才能克隆子模块。

[请注意,当将B作为子模块包含时,对库A使用pull不会更新库B。要同时更新B,您可以再次运行git submodule update --init --recursive

请参见https://git-scm.com/book/en/v2/Git-Tools-Submodules

© www.soinside.com 2019 - 2024. All rights reserved.