---
title: "Pulling private repos as git submodules in Code Studio"
date: "2024-07-10T05:47:19+00:00"
summary:
image:
type: "page"
url: "/acquia-cloud-platform/add-ons/code-studio/pulling-private-repos-git-submodules-code-studio"
id: "db26f618-4c00-497f-b5f2-17d10fb2bcaa"
---

In certain cases, you might need to pull a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) from a private repository into your Code Studio project.

This tutorial demonstrates how to authenticate with a private GitHub repository and pull the git submodule into your [Build Code job](/acquia-cloud-platform/add-ons/code-studio/docs/customizing-code-studio/drupal-auto-devops/autodevops-jobs#section-build-code-job).

Generating a GitHub personal access token
-----------------------------------------

1.  Log in to [GitHub](https://github.com/).
2.  Go to **Settings** > **Developer settings** > **Personal access tokens** \> [Tokens (classic)](https://github.com/settings/tokens).
3.  Select **Generate new token** > **Generate new token (classic)**.
4.  Select an expiration period.
5.  In **Select scopes**, select all items under **repo**.
    
    ![A GitHub interface for creating a personal access token named "GitlabCI" is shown. The token has no expiration date, and all scopes under repo are selected, including full control of private repositories, access to commit status, deployment status, public repositories, repository invitations, and read/write security events.](https://acquia.widen.net/content/vlarbiqa8q/web/code-studio_selecting-scope.png?w=720&v=0e21a793-3883-4af7-8ba7-4791c0f17d0b&itok=cMi6108O)
    
6.  Select **Generate token** and copy the token.

Adding GitHub authentication to the Build Code job
--------------------------------------------------

To authenticate with GitHub, use [before\_script](/acquia-cloud-platform/add-ons/code-studio/adding-custom-scripts-code-studio-jobs "Adding custom scripts to Code Studio jobs") to hook into the [Build Code job](/acquia-cloud-platform/add-ons/code-studio/docs/customizing-code-studio/drupal-auto-devops/autodevops-jobs#section-build-code-job). To use [before\_script](/acquia-cloud-platform/add-ons/code-studio/adding-custom-scripts-code-studio-jobs "Adding custom scripts to Code Studio jobs"), you require a [custom gitlab-ci.yml file](/acquia-cloud-platform/add-ons/code-studio/customizing-default-code-studio-pipeline "Customizing a default Code Studio pipeline").

1.  Add the `GITHUB_TOKEN` environment variable to Code Studio and set its value to the token that you copied from GitHub.
    
    For more information, see [Adding environment variables](/acquia-cloud-platform/add-ons/code-studio/customizing/default-code-studio-pipeline#section-adding-environment-variables#section-adding-environment-variables).
    
2.  Add a [before\_script](/acquia-cloud-platform/add-ons/code-studio/adding-custom-scripts-code-studio-jobs "Adding custom scripts to Code Studio jobs") to the [Build Code job](/acquia-cloud-platform/add-ons/code-studio/docs/customizing-code-studio/drupal-auto-devops/autodevops-jobs#section-build-code-job) in your project’s `gitlab-ci.yml` file:
    
        "Build Code":
                  before_script:
                    - |
                      # Manually trigger the submodule update
                      git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf git@github.com:
                      git submodule update --init --recursive
    

While defining git submodules in the `.gitmodules` file or in the `git submodule add` command, use SSH repository URLs if you use SSH URLs for local development. The pipeline replaces the SSH URLs with HTTPS URLs to authenticate with GitHub.