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

# Connect to Git

> Connect your Prod AI applications to a Git repository for version-controlled, PR-based development workflows.

Prod AI Git lets you connect each application to its own Git repository. Once connected, you get a full PR-based development workflow: edit in Prod AI, commit and push to your repo, open a pull request, and deploy once merged.

## Supported providers

Prod AI works with any of the following Git hosting providers:

| Provider | Remote URL format |
| - | - |
| **GitHub** | `https://github.com/org/repo.git` |
| **GitLab Cloud** | `https://gitlab.com/group/repo.git` |
| **GitLab Self-Hosted** | `https://gitlab.example.com/group/repo.git` |
| **Bitbucket** | `https://bitbucket.org/workspace/repo.git` |
| **Azure DevOps** | `https://dev.azure.com/org/project/_git/repo` |

Both HTTPS and SSH remote URL formats are supported.

## Repository model

Each Prod AI application is connected to **one Git repository**. The repository stores the application's definition files and a CI/CD pipeline configuration that keeps Prod AI in sync.

When you first connect an app, Prod AI initializes the repository with your application's files and creates a CI pipeline file appropriate for your provider.

## Branching model

Prod AI uses a two-branch workflow:

* **Working (live) branch**: the working branch created by Prod AI where all edits happen in the Prod AI editor
* **`main`** (or your repository's default branch): the production branch that represents what is deployed

![Branching diagram showing edits on the working branch merging into main for deployment](https://mintcdn.com/prod-ai/HpkY1I2odoCFS5ui/images/development-lifecycle/source-control/branching-diagram.svg?fit=max\&auto=format\&n=HpkY1I2odoCFS5ui\&q=85\&s=c2bb4c9292355ccd67eac9663d307e4b)

### Development workflow

1. You edit on the working branch in the Prod AI editor
2. When you want to sync your changes to Git, you make a commit
3. Once you want to promote your changes to production, you create a pull request in your Git repository
4. You go through your review process in Git and merge your PR when ready
5. These changes sync back to Prod AI via your CI/CD pipeline
6. You publish the synced changes to production from the **Deploy** tab in **Version history**

When the working branch is created for the first time and does not yet exist on the remote, it is based on the tip of your repository's default branch.

## Setup

### Prerequisites

Before connecting, you need:

* A Git repository hosted on one of the [supported providers](#supported-providers). **The repository must be empty**
* A **Personal Access Token (PAT)** with the required permissions for your provider (see [token permissions](#token-permissions) below)

### Connect an application to Git

1. Open your application in the Prod AI editor
2. Open **Git Settings** from the editor toolbar
3. Select your **Git provider** from the dropdown
4. Enter the **remote URL** of your repository
5. Enter your **Personal Access Token**
6. Click **Connect**

Prod AI validates your credentials, initializes the repository, and switches the editor to the working branch.

After connecting to Git, existing checkpoints created before the connection will no longer be restorable. Make sure you are satisfied with the current state of your application before proceeding.

### Set up the CI/CD pipeline

After connecting, Prod AI automatically adds a CI/CD configuration file to your repository and displays the exact secret name and setup steps for your Git provider. This pipeline syncs changes from `main` back to Prod AI whenever a merge occurs.

To complete setup:

1. Copy your Prod AI API token from **Personal Settings -> API Key** (also shown in the Git setup dialog)
2. In your Git provider, add the repository secret shown in the Git setup dialog with your API token value:
   * **GitHub:** Repository **Settings -> Secrets and variables -> Actions -> New repository secret**
   * **GitLab:** Repository **Settings -> CI/CD -> Variables** (mark as **Protected** and **Masked**)
   * **Bitbucket:** Repository **Settings -> Repository variables** (check **Secured**)
   * **Azure DevOps:** Create a pipeline from the generated YAML file and add the secret variable marked as **secret**

### Connect additional users

If another team member needs to work on an app that is already connected to Git, they need:

1. **Repository access**: ask a repo admin to add them as a collaborator
2. **A valid PAT**: when they open the app for the first time, Prod AI prompts them to enter their own personal access token

Each user authenticates independently with their own PAT, so commits are attributed to the correct author.

## Token permissions

The required PAT permissions vary by provider:

> [tab] GitHub
>
> Use a [fine-grained personal access token](https://github.com/settings/personal-access-tokens/new) scoped to your repository:
>
> | Permission | Access level |
> | - | - |
> | **Administration** | Read-only |
> | **Contents** | Read and write |
> | **Metadata** | Read-only |
> | **Workflows** | Read and write |
>
> If GitHub does not let you scope a fine-grained token to the repository, create a [classic personal access token](https://github.com/settings/tokens) with the **repo** and **workflow** scopes instead.

> [tab] GitLab
>
> Use a [personal access token](https://gitlab.com/-/user_settings/personal_access_tokens) or a project access token:
>
> | Setting | Value |
> | - | - |
> | **Scope** | `api` |
> | **Role** (project access tokens only) | Maintainer |
>
> For self-hosted GitLab, create the token from your instance's token settings page.

> [tab] Bitbucket
>
> Use a [repository access token](https://support.atlassian.com/bitbucket-cloud/docs/repository-access-tokens/) created in your repository's settings:
>
> | Permission | Access level |
> | - | - |
> | **Repositories** | Read and Write |
> | **Pull requests** | Read and Write |
> | **Pipelines** | Read |

> [tab] Azure DevOps
>
> Use a [personal access token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate) scoped to the organization that owns the repository:
>
> | Permission | Access level |
> | - | - |
> | **Code** | Read & Write |
> | **Project and Team** | Read |

## Using coding agents for Git

You can run Git operations directly from the editor chat by prompting in plain language. If the app is not yet connected to Git, asking for a Git operation triggers the setup flow automatically.

Once connected, you can prompt things like:

* *"What's the current git status?"*
* *"Show me the recent commits"*
* *"Commit my changes with the message 'fix: update button styles'"*
* *"Pull the latest changes from remote"*

## Deploying changes

When a change is merged to `main`, the CI/CD pipeline syncs that commit back to Prod AI. To publish:

1. Open the chat panel and switch to **Version history**
2. Open the **Deploy** tab (your repository's default branch)
3. Preview the synced version if you want to verify changes
4. Click **Publish** to make it live for end users

## Updating your Git token

If your personal access token expires or becomes invalid, open **Git Settings** from the editor toolbar. You do not need to disconnect the repository.

1. Enter a new PAT in the token field
2. Click **Save**

Prod AI validates the token and refreshes Git authentication in place.

## Disconnecting from Git

If you need to disconnect an application from Git:

1. Open **Git Settings** from the editor toolbar
2. Click **Disconnect**
3. Type the repository name to confirm

Disconnecting removes the link between the app and the repository. The repository itself is not deleted or modified.

## Troubleshooting

### "Invalid or insufficient permissions for this token"

The PAT cannot access the repository or is missing required scopes. Update the token in **Git Settings** (see [Updating your Git token](#updating-your-git-token)), and double-check the [token permissions](#token-permissions) for your provider.

### "Repository not found"

The remote URL is incorrect, the repository does not exist, or the token does not have access to it.

### CI/CD pipeline not syncing

Verify that:

* Your API token secret is set in your repository's CI/CD secrets using the exact name shown in the Git setup screen
* The API token has not been revoked or regenerated
* The generated CI/CD workflow file is present on your default branch


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