Git: How to remove submodule

How to un-submodule a git submodule?

Solution

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

project
├── .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.

Stackoverflow

  1. https://stackoverflow.com/questions/1759587/how-to-un-submodule-a-git-submodule

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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