These are the steps required to replace a directory with a submodule in git. Note: Assumes that you are currently working on branch called 'develop'
- Check out a new branch to make the changes on:
git checkout -b creating-submodule - delete directory to be replaced
rm -rf path/of/directory/to/be/replaced git add .thengit commit -m "removing local directory"- add the submodule:
git submodule add "https://github.com/repoName" path/of/directory/to/be/replaced git add .thengit commit -m "adding submodule"- delete the submodule directory if you don't do this git will throw a hissy when you try to checkout out develop to merge the changes in
git checkout developgit merge creating-submodule