Skip to main content

Clone submodules during deployment

Upsun allows you to use submodules in your Git repository. They’re usually listed in a .gitmodules file at the root of your Git repository. When you push via Git, Upsun tries to clone them automatically. The following example is based on a Bigfoot multi-app project which uses the following submodules: Diagram of a project containing multiple apps Say you have a multi-app project that includes the following submodules:
  • A BigFoot app
  • An API Platform v3, Admin component
  • A Gatsby frontend
  • A Mercure Rocks server
To import all the submodules, run the following commands from your multiple application project’s root folder:
Here is an example of a .gitmodules file:
When you run git push, you can see the output of the logs:
If your submodule contains an independent app, see how to configure it properly.

Update submodules

When you amend your submodules’ code, make sure your changes are applied by running the following commands before redeploying:
To specify which submodule needs to be updated, replace [submodule] with your submodule path.

Error when validating submodules

Using an SSH URL (git@github.com:...) to fetch submodules triggers the following error:
This is due to the fact that the Upsun Git server can’t connect to GitHub via SSH without being granted an SSH key to do so. To solve this issue, use an HTTPS URL (https://github.com/...) instead.

Use private Git repositories

When using Git submodules that are private repositories, URLs with the HTTPS protocol fail with errors such as the following:
To fix this, follow these steps:
  1. Change your module declarations to use SSH for URLs. Your existing declaration might look like this:
    .gitmodules
    Change this to the following:
    .gitmodules
  2. Add the project’s public key to your remote Git repository. If there are nested submodules in your submodule, then add the public key to those repositories as well. This allows your Upsun project to pull the repository from the remote Git service.
Deploy keys only grant access to a single repository, which can cause issues when attempting to pull several repositories to the same server. If your server needs access to multiple repositories, follow these steps:
  1. Create a machine user with access rights to each of the private repositories.
  2. Attach the deploy key to your machine user.

Removing submodules

These steps aren’t specific to Upsun, but kept as a reference for Git so that submodules are effectively removed before entering the build process.
  1. In your .gitmodules and .git/config files, delete the information related to the submodule you want to remove.
  2. Stage changes to .gitmodules:
  3. Remove the submodule from the repository (without trailing slash):
  4. Remove the submodule files in .git from the repository (without trailing slash):
  5. Commit the changes:
  6. Remove the submodule code locally, now no longer tracked:
Last modified on May 27, 2026