---
title: "Connect a repository"
url: https://docs.corefinity.com/guides/sites/code-and-deployments/connect-a-repository
type: guide
last_updated: 2026-11-13
feature: deployments
related:
  - https://docs.corefinity.com/api/reference/deployments/get-site-deployments.md
  - https://docs.corefinity.com/api/reference/deployments/create-site-deployment.md
  - https://docs.corefinity.com/api/reference/deployments/list-site-deployment-branches.md
  - https://docs.corefinity.com/api/reference/deployments/update-site-deployment-mode.md
  - https://docs.corefinity.com/api/reference/deployments/list-site-deployment-repositories.md
  - https://docs.corefinity.com/api/reference/deployments/update-site-deployment-repository.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_get.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_mode_set.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_repositories_list.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_branches_list.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_repository_set.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployment_trigger.md
---
# Connect a repository

Switch a site to Git deployments and choose the repository and branch it deploys from.

## Before you start

- You are an owner, or your role has **Manage Deployment Source** and **Manage Deployment Repositories**.
- Your organisation's GitHub, GitLab or Bitbucket account, or your own GitLab server, is connected: see [Repository connections](/guides/organisation/developers/repository-connections).
- The site keeps serving while it switches. On a Laravel site the application rebuilds once, and visitors may see an error page until it finishes.

## Connect the repository

1. **Open the site's deployments**

   Go to **Managed Websites**, choose the site, then **Deployments** under **Code & backups**. Choose the button **Switch to Git deployments…** on the **Deployment mode** card.

   _Screenshot: The Deployments section of a site on manual uploads: the Deployment mode card with the Switch to Git deployments button ringed._

2. **Switch to Git deployments**

   **How deployments work here** shows what moves: your current files become release 1, and uploads and configuration move to `shared/`. Choose **Continue**, then **Switch to Git deployments** to confirm.

   _Screenshot: The How deployments work here dialog: Manual uploads marked Current beside Git deployments, the site's folders now and after switching, and the Continue button._

3. **Choose the repository and branch**

   Choose **Connect a repository…** on the **Deployment mode** card. Choose the **Provider**, enter the **Repository** as `owner/name` and the **Branch**, then choose **Save repository**.

   _Screenshot: The Connect a repository dialog: GitHub selected under Provider, a repository and the branch main entered, Deploy on push ticked, and the Save repository button._

   Leave **Deploy on push** ticked to deploy every push to that branch. That also needs **Create Deployments**.

4. **Deploy the site**

   Choose **Deploy** in the site's header, or push to the branch. Until the first deployment the site runs its current files unchanged.

**Deployment mode** reads **Deploys from Git**, with the repository, the branch and **Deploy on push**. Use **Change repository…** to pick another.

_Screenshot: The Deployment mode card of a connected site: Deploys from Git, the repository address, the branch main, Deploy on push switched on and the Change repository button._

## Automate this

**API:** [Update a site's repository](https://docs.corefinity.com/api/reference/deployments/update-site-deployment-repository.md), scope `write`

```bash
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/deployments/repository \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "auto_deploy": false,
    "branch": "main",
    "connection_id": 4217,
    "contents": "site_content",
    "repo": "northwind-digital/harbourandfinch",
    "target_path": "wp-content/themes"
  }'
```

**MCP:** [`corestack_deployments_repository_set`](https://docs.corefinity.com/mcp/tools/corestack_deployments_repository_set.md), scope `write`

```json
{
  "name": "corestack_deployments_repository_set",
  "arguments": {
    "site_id": 4211,
    "connection_id": 12,
    "repo": "corefinity/example-shop",
    "branch": "main",
    "auto_deploy": false
  }
}
```

**Control Panel:** Managed Websites › your site › Code & backups › Deployments ([https://manage.corefinity.com/go/deployments](https://manage.corefinity.com/go/deployments))

## Related

- [Backups](/guides/sites/backups/snapshots): Take a backup before a change.
- [SSH keys](/guides/sites/access-and-security/ssh-keys): Add a key to log in over SSH.
- [Add a domain](/guides/sites/go-live/add-a-domain): Attach a domain to a site.
