Current folder structure
- /root: server code exists here
- /root/client: client code exists here (a subdirectory within the server's directory).
Current git tracking
- 1 repo tracking Server code in /root that gitignores the entire client directory
- 1 repo tracking Client code only within /root/client.
The Problem
I am trying to merge these two repos while keeping one as the subdirectory of the other, combining the historical commits of both (not losing any).
Findings So Far
I have found a lot of situations resolved on the Internet in which two repos have either 1) the same files or 2) will eventually be merged together at the same folder level, but have not found much on merging two repos if one is a subdirectory within another.
Any help would be greatly appreciated. Thank you!
This steps will merge both
master
branches:tmp_client
)tmp_client
) create a new folder calledclient
.tmp_client
to the newclient
folderAdd and commit the changes:
git add -A .
to add the changesgit commit -m "Move content to client folder"
Add a new remote branch for the server:
git remote add server git_server_repo_url
Pull changes from the server master branch
git pull server master
This will merge the changesPush changes to the server git repository
git push server master
PD: If you want to be sure all is ok in the server branch, you can create a new branch instead of pushing it to the working bramch of the server and then merge the new branch.