简体   繁体   中英

How to add two separate git repos into one repo as two directories while preserving commit history?

I was developing a full-stack web application and for that, I created two separate repositories for the front-end and back-end as I develop. The two repositories are,

  1. projectName_api
  2. projectName_client

Now I need to create one repository 'projectName' which contains these two separate git repositories as directories without deleting the commit history.

api --> projectName_api git repo

client --> projectName_client repo

|projectName
|--api
|--client
|--package.json

It will be better if the history of git repos can be put into branches like frontend and backend with separate history in those branches

The usual approach would be rather to use git submodules , referencing those two repositories in your main project repository.

That way:

  • they keep their history
  • they keep their own branches

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