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.

Get updates
You will get emails when I publish something new or have something useful to share about making profitable digital businesses less brittle, less founder-dependent and easier to run.

Expect practical notes on backups, safer deploys, infrastructure as code, observability, documentation and automation. Usually no more than one email per week. You can unsubscribe 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.