> ## 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. 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. (Optional) Under **Authentication**, enter a **GitHub organization** slug (the name that appears in `github.com/<slug>`) to register the app under that organization — you must be one of its owners. Leave the field empty to register the app under your personal GitHub account.
4. Click **Register the Packmind GitHub App**. GitHub opens so you can create the app, then returns you to Packmind automatically.
5. Once the app is registered, click **Install Packmind on GitHub**.
6. On GitHub, choose the organizations and repositories to grant access to, then confirm.
7. You're returned to Packmind automatically, and the connection is ready to use.

<Note>
  For team use, prefer registering the app under a GitHub organization so it
  isn't tied to one person's account. If you already registered it under a
  personal account, you can move it afterward on GitHub: open the app's
  settings, go to **Advanced**, and use **Transfer ownership** to hand it to
  your organization.
</Note>

<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.

For a self-managed GitLab, enter your instance URL (for example `https://gitlab.acme.io`). Packmind matches repositories to the connection by host, so a clone over HTTPS or SSH reaches the same connection.

## 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.

A repository the CLI already distributed to keeps its history when you add it: it moves under the connection with its existing targets instead of being created again, and the CLI-created entry for that host disappears once it holds no repository.

A repository you add from the Git connection panel is tracked on its default branch.

## Changing a Repository's Branch

Each repository is distributed to and tracked on one branch. To move it to another branch:

1. Open the connection from the **Connections** tab and click **Manage**.
2. Next to the repository, click **change branch** and type the branch name, then press Enter.
3. Click **Apply changes**.

The new branch replaces the current one rather than being added next to it. Packmind checks the branch with your Git provider first: a branch that doesn't exist is refused with an error under the field, and if the provider can't be reached nothing changes and you are asked to try again.

Changing the branch never deletes history. Distributions recorded on the branch you leave are kept, and switching back shows that branch's history again — see [Moving the Tracked Branch Is Reversible](/governance/distribution#moving-the-tracked-branch-is-reversible).

A repository added before branches were tracked may still list several branches. The first time you change its branch, Packmind starts tracking the one you chose and shows only that branch from then on.

## 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.


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