Remove git submodule created by mistake

  1. Make sure that the sub-directory/sub-module doesn't have .git directory. If it does, delete the .git directory inside the sub-directory/sub-module
    rm -rf [sub-module]/.git

     
  2. Clear the git cache
    git rm --cached [sub-module]