Submodule の削除は複雑です。
git --version
# git version 2.20.1 (Apple Git-117)場面毎の処理
git 管理はまだ
git submodule add直後であれば、インデックスに登録だけされている状態だと思うのでまずこれを戻します。
git resetその後 Submodule としたディレクトリを削除し、.gitmodulesからその Submodule 設定のセクションを削除します。
rm -rf
git config --local --remove-section submodule.
git config -f .gitmodules --remove-section submodule. すべての Submodule がいらないのであれば、.gitmodulesファイル自体を削除でも大丈夫です。
git で管理済かつ、Init 済の場合
# 紐付けを解除
git submodule deinit こちらの場合は上記のコマンドが.gitmodulesや.git/configの設定を自動で消してくれるため、git configでの編集は必要ありません。
共通処理
またその Submodule が必要になった場合に以下のようなエラー(警告)が出てしまうかもしれないので、Submodule のクローン済ディレクトリも削除します。それは.git/modules/<submodule-path>に置かれています。
#
# 次回以降、そのままでは以下が出てしまうので
#
# A git directory for '' is found locally with remote(s):
# origin git@github.com:user/repo.git
# If you want to reuse this local git directory instead of cloning again from
# git@github.com:user/repo.git
# use the '--force' option. If the local git directory is not the correct repo
# or you are unsure what this means choose another name with the '--name' option.
# 以下も削除しておく
rm -rf .git/modules/