Interview Prep/Git & GitHub/Submodules, LFS and Hooks

`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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Submodules, LFS and Hooks