简体   繁体   English

将GIT存储库子文件夹克隆到具有相同文件夹结构的现有Repo中

[英]Clone GIT Repository Subfolder into existing Repo with identical folder structure

Repository A) 资料库A)

MAIN ../repository_A/ 主要../repository_A/

../repository_A/some_directory/some_files

Repository B) 资料库B)

MAIN ../repository_B/ ../repository_B/

../repository_B/SRC/some_directory/some_files

The repository_B structure is identical to the repository_A structure, except for the /SRC/ directory which is in place because the main directory of repository_B has a .gitmodules file. 除了由于/ repository_B的主目录具有.gitmodules文件而存在的/ SRC /目录之外,repository_B结构与repository_A结构相同。

The ultimate goal is to clone/merge the content of /repository_B/SRC/ directory into /repository_A/ root - the folder structure is identical, so we need to write into existing folders of repository_A - for example write content of repository_B/SRC/includes directory into repository_A/includes . 最终目标是将/repository_B/SRC/目录的内容克隆/合并到/repository_A/根目录中-文件夹结构相同,因此我们需要写入repository_A的现有文件夹中-例如,写入repository_B/SRC/includes目录到repository_A/includes

Behind the task is that i have a modular system which is repository_A that is extended through modules which are represented by repository_B. 任务的背后是我有一个模块化系统,该系统是repository_A,该系统通过以repository_B表示的模块进行扩展。

Another option that would do the job too would be to mv repository_A into another directory so that the folder structure is identical to repository_B . 这将做的工作太另一种选择是,以mv repository_A到另一个目录中,这样的文件夹结构是相同的repository_B

You won't need to git clone, but you will need a git merge. 您无需进行git clone,但需要进行git merge。

  1. I would match repository A's folder structure to repository B, ie create /SRC/ folder to match repository B. 我将存储库A的文件夹结构与存储库B匹配,即创建/ SRC /文件夹以匹配存储库B。
  2. git commit/push repository's A's new structure. git commit / push存储库的A的新结构。
  3. If you want to merge repository B into repository A: 如果要将存储库B合并到存储库A中:

     cd path/to/repo-A git remote add repo-a path/to/repo-B git fetch repo-B git merge repo-B/master # or whichever branch you want to merge git remote remove repo-B 

Reference: How do you merge two Git repositories? 参考: 如何合并两个Git存储库?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM