# Connect GitHub repositories

Set token permissions, select repositories and keep their indexes current.

Canonical page: https://ontlgy.io/docs/sources/github/

An administrator connects GitHub once for the installation. Select only repositories whose indexed context is appropriate for everyone using that installation.

## Create a GitHub token

Use a dedicated account or a fine-grained token limited to the intended repositories.

| Token type | Permissions |
| --- | --- |
| Fine-grained | Selected repository access; **Contents: read**, **Metadata: read**, **Webhooks: read and write** |
| Classic | `repo`, `admin:repo_hook`, `read:org` |

Organization policy or approval requirements may affect which repositories the token can access. The token grants exactly the access allowed by its owner, scopes and repository selection; ontlgy cannot index repositories outside that access.

## Connect and select

1. Open **GitHub**, paste the token and connect.
2. Open **Repositories** and choose the repositories to index.
3. Wait for cloning and indexing. A failed index shows an error and a Retry action.
4. Verify a known symbol using [the first-query workflow](https://ontlgy.io/docs/start/first-query/).

The worker needs to remain running. Large repositories take longer. The API key used by your agent is separate from this GitHub credential.

## Keep indexes current

ontlgy creates repository webhooks for push updates at:

```text
https://YOUR_INSTALLATION/webhook/github
```

Set `ONTLGY_PUBLIC_URL` to a URL GitHub can reach. Each repository has its own webhook secret; unsigned requests are refused. If setup fails, correct the URL or permissions and use **Retry webhook**.

On a laptop without a reachable URL, use **Re-index now** instead. GitHub cannot send a webhook to your local `localhost` address.

## Credential handling

The token is encrypted in the control database with `ONTLGY_SECRET_KEY` and is not shown again in the UI. Host access and environment access remain privileged: the encryption key lives with the deployment. Disconnect the integration and revoke the token in GitHub when removing access.

Next: [Understand index freshness](https://ontlgy.io/docs/concepts/freshness/).
