How to fetch git submodules after downloading repository from GitHub

I’m working with a repository that contains submodules. On my local development setup, everything functions correctly. I’ve committed the .gitmodules configuration file and deployed it to production, but the submodules aren’t being downloaded automatically.

When I navigate to the submodule folders and run git pull, nothing occurs.

cd my-submodule-folder
git pull
# No output, nothing happens

What’s the correct approach to download and update these submodules in a freshly cloned repository? I need to make sure all the nested repositories are properly synchronized with their remote origins.

you gotta clone the repo first, then just run git submodule update --init --recursive. itll dl all the submodules and keep em in sync, real simple!

Hit this exact problem last month deploying to staging. When you clone a repo with submodules, git just creates empty directories - no actual git repo inside them yet. That’s why git pull fails in those folders. I fixed it by running git submodule update --init right after cloning. The --init flag grabs the config from .gitmodules and downloads everything. Got nested submodules? Add --recursive too. Now I just throw this into all my deployment scripts after git clone - saves me the headache every time.

Manual git commands work but get tedious with multiple environments and deployments.

I’ve hit this same problem on tons of projects. What finally fixed it was automating the whole process.

Instead of remembering those submodule commands every time, I built automation that triggers on production pushes. It clones the repo, initializes submodules, pulls latest changes, and notifies me when done.

Best part? It works the same across all environments. No more forgetting steps or empty submodule folders in production that work fine locally.

You can set this up easily with webhook triggers that listen for GitHub pushes, then run the full git sequence automatically. Takes 10 minutes to configure, saves hours later.

Check out Latenode for this kind of automation: https://latenode.com

This issue with submodules is quite frequent among users. When cloning a repository, the submodule directories might appear empty, which is expected behavior. Instead of executing git pull within those directories, initiate the process with git submodule init to configure them, followed by git submodule update to retrieve the actual content. For future cloning, you can simplify things by using git clone --recurse-submodules <repository-url>, which handles submodules automatically, preventing confusion around empty directories.