title: Convert a Git folder to a submodule retrospectively?
body: <p>Quite often it is the case that you're writing a project of some kind, and after a while it becomes clear that some component of the project is actually useful as a standalone component (a library, perhaps). If you've had that idea from early on, then there's a fair chance that most of that code is in its own folder.</p>
  
  <p>Is there a way to convert one of the sub directories in a Git project to a submodule?</p>
  
  <p>Ideally this would happen such that all of the code in that directory is removed from the parent project, and the submodule project is added in its place, with all the appropriate history, and such that all the parent project commits point to the correct submodule commits.</p>