`fatal: No url found for submodule path 'libs/common' in .gitmodules`
IntermediateTroubleshootingSubmodules, LFS and Hooks
Answer
Likely causes → The index contains a gitlink (mode 160000) for libs/common, but .gitmodules has no matching entry. Usually someone ran git add on a directory that was itself a Git repo (a nested clone), or deleted the .gitmodules section without removing the gitlink.
Diagnose →
git ls-files -s libs/common # mode 160000 = gitlink
cat .gitmodules
Fix → Either register it properly or remove the gitlink:
# register as a real submodule
git rm --cached libs/common
git submodule add https://github.com/org/common.git libs/common
# or remove it and vendor the files instead
git rm --cached libs/common && rm -rf libs/common/.git && git add libs/common
Prevent → Never git add a directory containing its own .git; Git warns with warning: adding embedded git repository — read it.
More on Submodules, LFS and Hooks
After 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.Intermediate`git submodule add` fails with `fatal: 'libs/common' already exists in the index`.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