简体   繁体   中英

Merge git repo with another repo's subdirectory, maintaining history

Let's say I have Repo A, which consists of the following structure:

Repo A:

├── content/
│   └── themes/
│       ├── myproject/
│       └── otherproject/
└── otherstuff/

myproject/ doesn't rely on otherproject/ or otherstuff/ , so I used git filter-branch to set up in Repo B with the following structure:

Repo B:

└── myproject/

I've made some commits to Repo B, but now, I would like to merge Repo B's myproject/ into Repo A's content/themes/myproject/ , keeping Repo A's history, as well bringing over the history and commit messages I made into Repo B since I branched off

Is there a way for me to achieve this?

Yes. Use filter-branch to split off the additional history you'd like to graft on to your existing history, push it there, then use git replace --graft and filter-branch to graft it on to that existing history.

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