Often, the scope of a project in source form grows as it develops as an idea. As a response, larger projects are often refactored into smaller submodules, some of which may be reused across other codebases as time goes on. To support this use-case, the author has developed a procedure to convert subdirectories of a given codebase directly into submodules, while also preserving all change history for those files. The procedure is outlined in the sections that follow.
Before making any of the destructive changes, described next, one must create a clean clone of the source repository. This repository is the one that contains the subdirectory that you want to isolate into a submodule:
# $source_repo_url is the URL of the source Git repository
git clone $source_repo_url