@mintuz gist contains instructions of how to preserve history of a subdirectory between repos, for example a template or lib within morph-renderer which you are transferring into morph-modules.
However this script doesn't work for a whole repository, such as something already (incorrectly) versioned or a standalone lib.
Based off of article found here: http://www.nomachetejuggling.com/2011/09/12/moving-one-git-repo-into-another-as-subdirectory
You have two repos here. morph-modules and my-module. We will be copying 'my-module' and preserving it's history into morph-modules/my-module.`
- Navigate in to
my-module.cd ~/workspace/my-module - Create a new directory within
my-module.mkdir temp-module - Move the contents of
my-moduleinto this subdir.mv !(temp-module) temp-module - Make a LOCAL commit. DO NOT PUSH TO REMOTE.
git commit -am "Prepare to move repo"
- Navigate to
morph-modules.cd ~/workspace/morph-modules - Add
my-moduleas a temporary remote.git remote add temp ~/workspace/my-module - Fetch.
git fetch temp. - Merge. This uses your pulls in your local copy and copies the history too.
git merge temp/master. - Delete the remote.
git remote rm temp.
You might need to resolve some conflicts in the normal manner, or follow Adam's instructions on dealing with mergepatches.