`git submodule add` fails with `fatal: 'libs/common' already exists in the index`.
IntermediateTroubleshootingSubmodules, LFS and Hooks
Answer
Likely causes → The path is already tracked, either as normal files (vendored copy) or as an old gitlink.
Diagnose → git ls-files -s libs/common | head (mode 100644 = files, 160000 = gitlink).
Fix →
git rm -r --cached libs/common
rm -rf libs/common
git commit -m "Remove vendored common"
git submodule add https://github.com/org/common.git libs/common
Prevent → When converting vendored code to a submodule, remove and commit the old files in a separate step first.
More on Submodules, LFS and Hooks
`fatal: No url found for submodule path 'libs/common' in .gitmodules`IntermediateAfter cloning, the submodule directories exist but are empty.Beginner`git submodule update` fails: `fatal: remote error: upload-pack: not our ref 3f2a9c1...` and `Fetched in submodule path 'libs/common', but it did not contain 3f2a9c1. Direct fetching of that commit failed.`Intermediate`git status` keeps showing `modified: libs/common (new commits)` even though you never touched it.BeginnerYou committed inside a submodule, ran `git submodule update`, and your commits vanished.IntermediateRe-adding a removed submodule fails: `A git directory for 'libs/common' is found locally with remote(s): origin https://github.com/org/common.git`.Advanced