Files
holocron/plugins/git/skills/git-submodules/references/removal.md
Defame1297 261e5b5491 refactor(git-submodules): retrofit to the ADR-0020 context contract
Description 480 -> 248 chars, body 1011 -> 347 words. The single
submodules.md splits into setup-and-update, urls-and-config, and removal.

Restores three regressions the first pass introduced: 'repointing' as the
trigger for the URL branch, which had none while the boundary clause
steered those queries to git-remotes; clone and absorbgitdirs in the output
enum, which dispatch still routed to; and status --cached, the flag that
makes the pre-commit pointer gate verifiable.
2026-08-30 13:10:53 +00:00

1.1 KiB

topic, source_keys
topic source_keys
submodules
git-scm-submodule-docs

Removing and deinitializing a submodule

Both operations are destructive. Confirm with the user before executing either.

deinit is not removal

git submodule deinit <path>   # --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

git submodule deinit -f <path>    # unregister from .git/config
git rm <path>                     # drop the .gitmodules entry and the gitlink from the index
rm -rf .git/modules/<name>/       # stale git dir: not tracked, not cleaned up by git
git commit -m "chore: remove <name> submodule"

The third step is the one that gets skipped. .git/modules/<name>/ survives git rm, and while it is present Git refuses to add a submodule at the same path again.