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 standal
First change dir to folder which will be a submodule. Then:
git init
git remote add origin repourl
git add .
git commit -am'first commit in submodule'
git push -u origin master
cd ..
rm -rf folder wich will be a submodule
git commit -am'deleting folder'
git submodule add repourl folder wich will be a submodule
git commit -am'adding submodule'