Git has a very interesting submodule feature when it comes to linking several projects together. It allows linking a directory to another git repository, for instance for a C/C++ library to integrate statically into a main project.
Adding the submodule is fairly simple, but removing the traces of a submodule is not necessarily trivial, since git does not provide a git submodule rm command.
Here is the solution, for a submodule installed in the directory lib/custom_submodule.
git submodule deinit lib/custom_submodule
git rm lib/custom_submodule
rm -Rf .git/modules/lib/custom_submodule
This will remove the submodule link from the repository and its references in the local repository.
If you want to natively integrate a submodule, copy the lib/custom_submodule directory beforehand and after the git rm, put it back in its original location, then add the files to the repository with git add.