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

Time:07-27

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

CodePudding user response:

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
  • Related