Demo
How it works
- Install the Xata GitHub App in a GitHub user account or organization.
- Link that GitHub App installation to a Xata organization.
- In the Xata project settings, choose the GitHub repository and the Xata root branch.
- When a pull request is opened or reopened, Xata creates a child branch from the selected root branch.
- When the pull request is closed, Xata deletes the preview branch if it is still a child of the selected root branch.
Prerequisites
- Access to the Xata organization and project that you want to link.
- Permission to install or request GitHub Apps for the GitHub account or organization that owns the repository.
- The Xata GitHub App must be granted access to the repository you want to link.
If you are not a GitHub organization owner, GitHub may submit an installation request instead of installing the app immediately. A GitHub organization owner must approve the request before you can link a repository in Xata.
Install the GitHub App
- Open the Xata Console.
- Go to the project you want to connect.
- Open Project Settings.
- In GitHub Repository, click Install GitHub App.
- In GitHub, choose the account or organization where the app should be installed.
- Choose whether Xata can access all repositories or only selected repositories.
- Complete the GitHub installation flow.


Link a repository to a project
After the GitHub App is installed, configure the repository mapping from the project settings page:- Open Project Settings.
- In GitHub Repository, choose the repository to link.
- Choose the Root branch.
- Click Save settings.

main, each preview branch starts as a child of main and contains the schema and data from main at the moment Xata creates the branch.
A Xata project can have one linked GitHub repository. A GitHub repository can be linked to one Xata project at a time.
Pull request behavior
When a pull request is opened or reopened in the linked repository, Xata:- Finds the repository mapping for the GitHub repository.
- Creates a child branch from the configured root branch.
- Names the Xata branch after the pull request’s source branch.
- Posts or updates a comment on the pull request with the preview branch status.
- Finds the Xata branch with the same name as the pull request’s source branch.
- Deletes it only if it is a child of the configured root branch.
- Posts or updates a comment on the pull request when the preview branch is deleted.
Manage repository access
If a repository does not appear in the repository selector, the GitHub App probably does not have access to it. From the project settings page, use the manage repository access or manage installations link to open the GitHub App installation settings. In GitHub, grant the Xata GitHub App access to the repository, then return to Xata and refresh the project settings page.Manage installations
Use the GitHub App installations page in Xata to view the GitHub App installations linked to your Xata organizations. From there, you can:- Open GitHub to manage repository access for an installation.
- Install the Xata GitHub App in another GitHub account.
- Uninstall a GitHub App installation.
Remove a repository mapping
To stop creating preview branches for a project without uninstalling the GitHub App:- Open Project Settings.
- Find GitHub Repository.
- Click Remove.
- Confirm the removal.
GitHub Actions comparison
The GitHub App and the GitHub Actions workflows solve related but different problems:| Use case | Recommended approach |
|---|---|
| Automatically create and clean up one preview branch per pull request | Xata GitHub App |
| Run custom commands, migrations, tests, deployment steps, or comments in CI | GitHub Actions workflow |
| Bulk cleanup of branches by naming convention or age | Bulk delete workflow |