For years, i’ve been searching the internet every time i want to do this. Various guides have come and gone. I rarely deal with git submodules anymore since the dawn of Bundler, but every now and then i find i want to remove a submodule in order to convert to bundler.
So once and for all, here’s the process, for example i am deleting a cucumber rails plugin:
Remove the three lines from .gitmodules
[submodule "vendor/plugins/cucumber"] path = vendor/plugins/cucumber url = git://github.com/cucumber/cucumber.git
Remove the two lines from .git/config
[submodule "vendor/plugins/cucumber"] url = git://github.com/cucumber/cucumber.git
Delete the git reference file that holds the submodule’s SHA commit id. Note the important lack of a trailing slash.
git rm --cached vendor/plugins/cucumber
Git will now see the entire directory as new files, because it’s no longer a submodule. Now you are free to delete the whole lot.
rm -rf vendor/plugins/cucumber/
And now you can add it to your Gemfile to use with bundler :)