Note this is NOT a complete duplicate of Detach (move) subdirectory into separate Git repository, which shows how to correctly carve out a subdirectory from an existing repo and create a new repo for it so history is ported to the new repo. But it doesn't show what to do if the subdirectory was incorrectly carved out, hence not porting the history, and how to port it later.
In my case, someone in my company moved an existing directory in an existing Git repo months ago into its own Git repo. That is...
Old repo structure
/projectDir/module1
/module2
/module3
to
Repo1:
/projectDir/module1
/module2
Repo2:
/module3
However, the person that did it did NOT follow the above post when the subdirectory was carved out into a new repo, and hence the history wasn't ported over from the old repo to the new repo. In the meantime, two things have happened, namely,
- The subdirectory was removed from the old repo
- the new repo has been used, thereby accumulating its own new history
How can I port the history over from the old repo to the new repo, while preserving the current history of the new repo.