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

You committed inside a submodule, ran `git submodule update`, and your commits vanished.

IntermediateTroubleshootingSubmodules, LFS and Hooks
Answer

Likely causes → Submodules are checked out in detached HEAD at the commit the parent records. Your commits were made on that detached HEAD, and submodule update moved HEAD back to the recorded commit, leaving yours unreferenced.

Diagnose → git -C libs/common reflog -10 shows your commits.

Fix →

cd libs/common
git branch rescue <sha-from-reflog>
git switch main && git merge rescue && git push origin main
cd .. && git add libs/common && git commit -m "Bump common"

Prevent → Always git switch <branch> inside a submodule before committing, or use git submodule update --remote --merge to work on a branch.

All Git & GitHub questions Roadmap: Git & GitHub

More on Submodules, LFS and Hooks