--- topic: submodules source_keys: - git-scm-submodule-docs --- # Removing and deinitializing a submodule Both operations are destructive. Confirm with the user before executing either. ## `deinit` is not removal ```bash rtk git submodule deinit # --all for every submodule, -f if locally modified ``` `deinit` clears the submodule's section from `.git/config` and empties its working tree. The `.gitmodules` entry and the gitlink in the superproject's index are untouched, so the submodule is still registered and a later `update --init` brings it straight back. Use it to reclaim disk space or to reset a broken checkout, not to delete a dependency. ## Full removal, in order ```bash rtk git submodule deinit -f # unregister from .git/config rtk git rm # drop the .gitmodules entry and the gitlink from the index rm -rf .git/modules// # stale git dir: not tracked, not cleaned up by git rtk git commit -m "chore: remove submodule" ``` The third step is the one that gets skipped. `.git/modules//` survives `rtk git rm`, and while it is present Git refuses to add a submodule at the same path again.