Interview Prep/Git & GitHub/Scale, Submodules, LFS and GitHub Automation

You must remove a submodule completely.

BeginnerScenarioScale, Submodules, LFS and GitHub Automation
Answer

Situation read → A submodule leaves traces in three places: index, .gitmodules and .git/modules.

What I'd do →

  1. git submodule deinit -f libs/shared.
  2. git rm -f libs/shared (also edits .gitmodules).
  3. rm -rf .git/modules/libs/shared.
  4. Commit the change.

Why → Skipping the last step leaves stale metadata that breaks re-adding it later.

Interview tip → Know that deleting only the directory is a classic mistake.

All Git & GitHub questions Roadmap: Git & GitHub

More on Scale, Submodules, LFS and GitHub Automation