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

# Connect GitHub

> Add documentation files from a GitHub repository to your chatbot with a personal access token.

Use this guide to add files from a GitHub repository, such as `README.md` files or a `docs` folder. SiteGPT connects with a GitHub personal access token that you create. There is no "Sign in with GitHub" step.

## Before you start

* An active plan. Each plan has a page limit. See [Plans and limits](/docs/reference/plans-and-limits).
* The Super Admin, Admin, or Manager role on the chatbot. Agents cannot add content.
* Permission in GitHub to create a fine-grained personal access token for the repository owner.
* A workspace without HIPAA mode. HIPAA workspaces cannot use cloud connectors. See [HIPAA](/docs/account/hipaa).

## Create a token in GitHub

<Steps>
  <Step title="Open token settings">
    In GitHub, go to **Settings** > **Developer settings** > **Personal access tokens** > **Fine-grained tokens**, and generate a new token.
  </Step>

  <Step title="Name the token">
    Enter a **Token name**.
  </Step>

  <Step title="Choose the owner">
    In **Resource owner**, select the user or organization that owns the repository.
  </Step>

  <Step title="Set the expiration">
    Choose an **Expiration**. The SiteGPT form recommends **No expiration**. If the token expires, SiteGPT can no longer read the repository. Auto-sync and resync then fail until you add a new token with **Update Access Token**.
  </Step>

  <Step title="Choose repositories">
    Under **Repository access**, select **Only select repositories** and choose the repositories.
  </Step>

  <Step title="Set the permission">
    Under **Permissions**, add **Contents** with **Read-only** access.
  </Step>

  <Step title="Copy the token">
    Generate the token and copy it.
  </Step>
</Steps>

GitHub can change its menu names. If a label differs, follow GitHub's own guide for fine-grained tokens.

## Connect the repository

<Steps>
  <Step title="Open the GitHub connector">
    In the chatbot sidebar, go to **Files & Data Sources** > **GitHub**.
  </Step>

  <Step title="Start a connection">
    Select **Connect Account**. The **New GitHub Connection** form opens.
  </Step>

  <Step title="Name the connection">
    In **Connection Label**, enter a name you will recognize, for example `Product docs`.
  </Step>

  <Step title="Enter the owner">
    In **Repository Owner**, enter the same owner you chose for the token, for example `my-org`.
  </Step>

  <Step title="Paste the token">
    Paste the token into **Personal Access Token**.
  </Step>

  <Step title="Save the connection">
    Select **Create Connection**.
  </Step>
</Steps>

## Choose the files

After you create the connection, the **Add GitHub Files** form opens. To open it later, go to **Files & Data Sources** > **GitHub**, select the settings icon, and select **Add files** or **Add more files**. **Repository Owner** is already filled in from the connection.

<Steps>
  <Step title="Enter the repository">
    In **Repository Name**, enter the repository name, for example `example-repo`.
  </Step>

  <Step title="Enter the branch">
    In **Branch Name**, enter the branch, for example `main`. Branch names that contain a slash, such as `feature/docs`, do not work.
  </Step>

  <Step title="Enter file patterns">
    In **File patterns to add**, enter one pattern per line. See [File patterns](#file-patterns).
  </Step>

  <Step title="Choose a schedule (optional)">
    In **Auto Sync Frequency**, choose how often SiteGPT reads the repository again. This field shows only if your plan includes auto-sync.
  </Step>

  <Step title="Add the files">
    Select **Add Files**. The message "Added GitHub files to the queue" appears.
  </Step>
</Steps>

## File patterns

Patterns use glob syntax and match file paths from the repository root.

| Pattern             | Matches                                  |
| ------------------- | ---------------------------------------- |
| `**/*.md`           | All Markdown files in the repository     |
| `docs/*.txt`        | Text files directly in the `docs` folder |
| `docs/**`           | All files in `docs` and its subfolders   |
| `README.md`         | Only the `README.md` file at the root    |
| `!docs/internal/**` | Leaves out files in `docs/internal`      |

* Enter at least 1 and up to 10 patterns.
* Patterns are case-sensitive.
* A set of patterns can match up to 5,000 files. If it matches more, use more specific patterns.
* If no files match, SiteGPT shows "No files matched the provided patterns".
* SiteGPT always leaves out `.env` files, `node_modules`, `.git`, and lock files such as `package-lock.json`.

Match documentation files, not source code. Every matched file uses pages of quota: one page for every 2,500 characters.

## Check that it works

1. Go to **Files & Data Sources** > **Files List**.
2. Wait for the files to show **Success**.
3. Ask the chatbot a question that one of the files answers.

## Keep the repository up to date

If you chose an **Auto Sync Frequency**, SiteGPT reads the repository again on that schedule. It adds new files that match your patterns and refreshes existing files. It does not remove files that you deleted from the repository. Delete those in **Files List**.

To refresh now, select the files in **Files List** and select **Resync N Selected**. For schedules and plans, see [Keep content up to date](/docs/guides/content/keep-content-up-to-date).

## Change or remove the connection

Open **Files & Data Sources** > **GitHub** and select the settings icon. Then:

* To use a new token, select **Update Access Token**.
* To disconnect, select **Revoke Access**. The content that is already trained stays. To remove it, delete the files in **Files List**.
