> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mithunai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect a private GitHub repository

> Read a private repository's files, issues, pull requests or discussions with a read-only GitHub token you create. A public repository needs none of this.

To read a private GitHub repository, create a read-only fine-grained token for it in GitHub, then tick **This repository is private** when you connect the source and choose or add a GitHub connection. A public repository needs no token.

> [!WARNING]
>
> Whatever the token can read, your assistant can quote to anyone who can ask it. Give it access to
> the repositories you connect and nothing else. See [Saved connections](https://docs.mithunai.com/knowledge/connections.md).

> [!NOTE]
>
> Private repositories are in **beta**. They are read by the same client as public ones, with only
> the token changed, but this has not yet been run against a real private repository. Tell your
> MITHUNAI contact if a sync does not read what you expect.

## What you need

* A GitHub account that can read the repository.
* The **owner or admin** role in your MITHUNAI organisation.

## 1. Create the token in GitHub

1. In GitHub, click your profile picture, then **Settings**.

2. In the left sidebar, click **Developer settings**, then under **Personal access tokens**, **Fine-grained tokens**.

3. Click **Generate new token** and give it a name, such as `MITHUNAI`.

4. Choose an **Expiration**. Note the date: you will replace the token before then.

5. Under **Resource owner**, choose the account or organisation that owns the repository. If it belongs to an organisation, the organisation may need to approve the token.

6. Under **Repository access**, choose **Only select repositories** and pick the repositories you will connect.

7. Under **Permissions → Repository permissions**, set to **Read-only** only what you will read:

   * **Contents**, for the repository's files.
   * **Issues**, for issues.
   * **Pull requests**, for pull requests.
   * **Discussions**, for discussions.

   *Metadata: Read-only* is added by GitHub itself. Give nothing *Read and write*.

8. Click **Generate token** and copy it. GitHub shows it only once.

## 2. Connect the repository

1. In the console, open **Sources** and choose **Connect source**, then **GitHub**.
2. Enter the repository as `owner/repo`, and choose what to read: files, issues, pull requests or discussions.
3. Tick **This repository is private**.
4. If you have no GitHub connection yet, the form to add one opens. Enter a **Connection name** of your own and paste the **Token**, then choose **Save connection**. Otherwise choose the connection from the list.
5. Choose **Connect source**.

One GitHub connection can be used for every repository its token can read.

## What changes for a private repository

Nothing about what is read: the same files, issues, pull requests and discussions as a public repository, described on [Sources](https://docs.mithunai.com/knowledge/sources.md#github). The difference is only whose token reads them: yours, never the deployment's. If the connection stops working, the sync fails; it never quietly reads the repository another way.

## When something goes wrong

| What you see | Why, and what to do |
| - | - |
| *The repository could not be found* | The token cannot see the repository: it was not selected under *Repository access*, or the organisation has not approved the token. |
| *The knowledge source rejected the configured credential* | The token expired or was revoked. [Replace the token](https://docs.mithunai.com/knowledge/connections.md#replace-a-token). |
| *The configured credential may not read this repository* | The token is missing a read permission for what you chose to read (step 7). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.