git submodule deinit wipes working tree without warning or checking for local changes
Open 💬 2 comments Opened Jun 16, 2026 by twall
Bug
Claude ran git submodule deinit -f <path> followed by git rm when asked only to remove the submodule reference. This wiped the entire working tree of the submodule, including:
- Uncommitted local changes (the submodule showed as
Mingit statusbefore the operation) - Local IDE settings and other gitignored files that only existed on disk
Expected behavior
Before running git submodule deinit, Claude should:
- Check
git -C <submodule-path> statusfor uncommitted changes - Check for gitignored files worth preserving (IDE settings, etc.)
- Warn the user and ask for confirmation if anything would be lost
- Default to
git rmonly (removes submodule tracking, leaves working tree intact) unless the user explicitly asks to clear the directory
Actual behavior
Claude ran git submodule deinit -f <path> && git rm -f <path> immediately, clearing the working tree without any prior check or warning. The user had asked only to "remove webapp as a submodule" — not to delete the local files.
Impact
- Lost uncommitted local changes (unrecoverable)
- Lost gitignored local files (IDE project settings — unrecoverable)
Suggested fix
Treat git submodule deinit as a destructive operation requiring the same caution as rm -rf. Always check for local state first and confirm with the user before proceeding.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗