简体   繁体   中英

Clone GIT Repository Subfolder into existing Repo with identical folder structure

Repository A)

MAIN ../repository_A/

../repository_A/some_directory/some_files

Repository B)

MAIN ../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.

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 .

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.

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 .

You won't need to git clone, but you will need a git merge.

  1. I would match repository A's folder structure to repository B, ie create /SRC/ folder to match repository B.
  2. git commit/push repository's A's new structure.
  3. If you want to merge repository B into repository 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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