Access multiple Git repositories in a project

Prerequisites

This guide assumes that you’re familiar with Git, generating SSH keys and connecting a Git repository to your Valohai project. If you’re not familiar with these see our guide on Connect to a Git repository

Each Valohai project can be connected to one Git repository at a time.

Sometimes you might need to access another repository from your Valohai project. This could be because you’re developing a library seperately in another Git repository or have some other files that you need to access from another seperate repository, while keeping the two projects seperate.

See also

Add a submodule to your Git repository

Private submodules

Make sure the URL of the submodule is in the following format git@mygitprovider.com:<username>/<repository>.git.

Valohai won’t be able to fetch a private submodule using the HTTPS address.

You can add a new submodule with git submodule add.

git submodule add git@mygitprovider.com:<username>/<repository>.git
git add .
git commit -m "Added submodule"
git push

Configure access for Valohai

You’ll need to provide Valohai access to both the main repository and all the submodule repositories.

You can provide only one SSH key in the Valohai project’s settings. Make sure this key has access to all the required repositories.

GitHub

When using repositories that don’t have a submodule you can generate a deploy key and add it to your Valohai project.

GitHub allows a deploy key to be used only in one project at a time. This means that you can’t use the same deploy key in your main repository and in your submodule repositories.

To allow Valohai to fetch a repository with submodules you’ll need to:

  1. Generate and add a new SSH key to your GitHub profile

  2. Go to your Valohai project settings link the main repository using the generated SSH Key.

You can now fetch the repository and it’s submodules on Valohai.

GitLab

GitLab allows you generate a deploy key and use it across multiple repositories.

  1. If you haven’t already, follow the Integrating with GitLab guide to create a deploy key for your main repository

  2. On Gitlab open the repository of the submodules project

  3. Open Project -> Settings -> Repository -> Deploy keys

  4. Open the Privately accessible deploy keys tab

  5. Enable the key you’re using in your main repository

You can now fetch the repository and it’s submodules on Valohai.

Bitbucket

  1. If you haven’t already, follow the Integrating with Bitbucket guide to create a deploy key for your main repository

  2. Add the same deploy key to the other repository that you’re using as a submodule

You can now fetch the repository and it’s submodules on Valohai.