My project consists of two folders, each with its own repository:
project/
|--frontend/
|--|--.git
|--backend/
|--|--.git
So far I have worked on them locally. Now I want to create one global repository for my project to push it into remote while saving both histories in it. What is the right way to do it?
project/
|--.git - has entire history of project (both folders)
|--frontend/
|--|--.git - can be deleted if method requires it
|--backend/
|--|--.git - can be deleted if method requires it
I suspect you can do this by moving the path of each and merging one into the other
This assumes it's desirable to add the frontend into the backend repository, though this might not be the case for you - repeat the steps for each if creating a new repository
WARNING I HAVE NOT TESTED THIS YET
Make a backup of your repositories
Check out a custom branch (in backend)
update the remote so they are part of the same repository
get the remote from each
update the backend's remote
Move the contents of each into its future name
join the unrelated histories
The branches do not share a common history
Git refusing to merge unrelated histories on rebase
the repositories are now merged
extras
I highly recommend adding a file with notes about what happened and at what specific commits
prefixing your commits with a unique string may help you find them later