> ## Documentation Index
> Fetch the complete documentation index at: https://nextjs-egg.nyxel.my.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Private Repos

> Authenticate with GitHub or GitLab to clone private repositories.

By default, the egg clones public repositories without any credentials. To access a private repository, you need a personal access token. The egg injects it into the Git URL at startup — you never embed credentials in the URL yourself.

<Warning>
  Never put your access token directly in the `GIT_URL` field. The egg handles credential injection automatically.
</Warning>

<Steps>
  <Step title="Generate a personal access token">
    <Tabs>
      <Tab title="GitHub">
        1. Go to [GitHub Settings → Tokens](https://github.com/settings/tokens).
        2. Click **Generate new token** and select **Classic**.
        3. Give the token a name and check the **`repo`** scope.
        4. Click **Generate token** and copy the value — you won't see it again.
      </Tab>

      <Tab title="GitLab">
        1. Go to **User Settings → Access Tokens** in your GitLab instance.
        2. Create a new token with the **`read_repository`** scope.
        3. Copy the token value before leaving the page.
      </Tab>
    </Tabs>
  </Step>

  <Step title="Set your username in the panel">
    In your server's startup variables, set `USERNAME` to your GitHub or GitLab username (the same account that owns the repository).
  </Step>

  <Step title="Set your access token in the panel">
    Set `ACCESS_TOKEN` to the token you generated in step 1.
  </Step>

  <Step title="Set the repository URL">
    Set `GIT_URL` to the plain HTTPS URL of your repository — do **not** embed credentials in the URL.

    ```text Correct theme={null}
    https://github.com/user/repo
    ```

    ```text Incorrect — do not do this theme={null}
    https://user:token@github.com/user/repo
    ```

    The egg constructs the authenticated URL internally using `USERNAME` and `ACCESS_TOKEN`.
  </Step>

  <Step title="Start the server">
    Start (or restart) the server. The egg injects your credentials into the Git URL automatically before cloning or pulling.
  </Step>
</Steps>

<Tip>
  Tokens with the `repo` scope can access all your repositories. Create a fine-grained token with access only to the specific repo for better security.
</Tip>
