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

# Git Repository Connection

<Info>
  Only users with **Admin** privileges can configure Git providers and manage
  repositories. If you need to connect repositories, contact your organization
  administrator.
</Info>

Packmind connects to your GitHub and GitLab repositories so it can distribute your standards, commands, and skills. Before you can distribute, an administrator connects at least one Git provider from **Settings** → **Git Providers**.

## Supported Git Providers

Packmind supports **GitHub** and **GitLab**. You add and manage connections from **Settings** → **Git Providers**, on the **Connections** tab. Click **Add connection** to open the connection panel.

For GitHub, you can authenticate with the **GitHub App** (recommended) or a **personal access token**. GitLab connections use a personal access token.

## Connecting GitHub

### GitHub App (recommended)

The GitHub App is the recommended way to connect GitHub repositories:

* **Scoped access** — you choose exactly which organizations and repositories Packmind can reach. Nothing else is visible to Packmind.
* **Automatic credential rotation** — Packmind refreshes its access on its own, so there's no token to create, store, or renew.

How you connect depends on whether you use Packmind Cloud or a self-hosted instance.

#### On Packmind Cloud

1. Go to **Settings** → **Git** and click **Add connection**.
2. Select **GitHub** as the vendor.
3. (Optional) Enter a **display name** to identify this connection later.
4. Under **Authentication**, click **Install Packmind on GitHub**.
5. On GitHub, choose the organizations and repositories you want to grant access to, then confirm.
6. You're returned to Packmind automatically, and the connection is ready to use.

#### On self-hosted Packmind

The first time you connect, you register a Packmind GitHub App for your organization. This is a one-time setup — every later GitHub connection reuses it.

1. Go to **Settings** → **Git** and click **Add connection**.
2. Select **GitHub**.
3. Under **Authentication**, click **Register the Packmind GitHub App**. GitHub opens so you can create the app for your organization, then returns you to Packmind automatically.
4. Once the app is registered, click **Install Packmind on GitHub**.
5. On GitHub, choose the organizations and repositories to grant access to, then confirm.
6. You're returned to Packmind automatically, and the connection is ready to use.

<Note>
  After the app is registered, every new GitHub connection in your organization
  reuses it — you only register once. To remove the registration, use **Revoke
  registration**. This is only available once no connections are still using the
  app, so delete those connections from the **Connections** tab first.
</Note>

### Personal access token

If you can't use the GitHub App, you can connect with a personal access token instead. In the **Add connection** panel, choose **Use a personal access token instead**, then:

1. Go to **GitHub Settings** → **Developer settings** → **Personal access tokens**.
2. Click **Generate new token** (classic).
3. Permissions must include **Contents: read/write** (or the `repo` scope for classic tokens).
4. Copy your token (it starts with `ghp_` or `github_pat_`) and paste it into Packmind.

<Note>
  Personal access tokens don't rotate automatically — you'll need to renew them
  before they expire. Prefer the GitHub App when you can.
</Note>

## Connecting GitLab

GitLab connections use a personal access token:

1. Go to **GitLab User Settings** → **Access Tokens**.
2. Create a new token with the `api` scope (full API access).
3. Copy your token (it starts with `glpat-`) and paste it into Packmind.

## Managing Repository Access

To change which repositories a GitHub App connection can reach, open the connection from the **Connections** tab and use **View Packmind on GitHub**. This opens the Packmind app's page on GitHub, where you can add or remove repositories. The new access takes effect in Packmind without reconnecting.

## Adding Repositories

Once you've added your providers, **add repositories** for each provider.

When you add a Git repository, Packmind automatically creates a default target with the root path "/" for that repository. This allows you to immediately start distributing standards and commands to the entire repository. You can later create additional targets for specific paths within the repository if needed.

## Distribution Targets

Before distributing your standards and commands, you can configure targets in **Settings** → **Distribution** → **Targets**. A target defines a specific path within your Git repository where standards and commands will be distributed.

Targets are particularly useful in monorepo environments where you want to apply different standards to different parts of your codebase. For example:

* `/frontend/` - Apply frontend-specific standards to your React components
* `/apps/api/` - Distribute backend standards to your API code
* `/packages/shared/` - Apply shared library standards to common utilities
* `/` (Created by default when you add a Git Repo)

Each target creates instruction files in its specified path, allowing AI agents to follow the appropriate standards based on the code they're working with.
