Git: How to remove submodule

How to un-submodule a git submodule?


Assuming you have the following repository structure, and you are under project/ directory.

├── .git
├── some_dir
├── some_file
└── sub_module_dir
    ├── .git
    └── more_files

I could un-submodule my sub_module_dir (e.i: remove git submodule without deleting the directory) with:

git rm --cached ./sub_module_dir

After this, the files inside directory were available to parent git repository for tracking, and sub_module_dir was visible as deleted in git status (as it has been removed as a submodule). But don’t worry, this command doesn’t delete the directory.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s