Fixing an Empty Git Submodule Folder After a Clone

TAGS: GIT

Here’s something I stumble over almost every time I clone a git repository with submodules.

Those darn folders are empty and using the project fails. Here are two ways to fix that:

Clone With The Recursive Flag

When issuing your git clone, add a --recursive flag. It will look like this:

$ git clone git@github.com:user/project.git --recursive

And as easy as that, your submodules are there.

If you cloned your repo and don’t mind starting over - delete the freshly cloned repository and add that --recursive to the command.

If you don’t want to start over…

Fix Those Submodules With An Init

You can fix your submodules in hindight, with this command:

$ git submodule update --init

This will fill in those missing pieces and you’ll be able to finally get back to interacting with your git project - submodules and all.

As I’m writing this, I’m considering to add --recursive by default when cloning something in the future. This way, I’ll never stumble over broken submodules again.

Subscribe to my newsletter!
You'll get notified via e-mail when new articles are published. I mostly write about Docker, Kubernetes, automation and building stuff on the web. Sometimes other topics sneak in as well.

Your e-mail address will be used to send out summary emails about new articles, at most weekly. You can unsubscribe from the newsletter at any time.

Für den Versand unserer Newsletter nutzen wir rapidmail. Mit Ihrer Anmeldung stimmen Sie zu, dass die eingegebenen Daten an rapidmail übermittelt werden. Beachten Sie bitte auch die AGB und Datenschutzbestimmungen .

vsupalov.com

© 2024 vsupalov.com. All rights reserved.