# Git Sync

> Keep workflows and knowledge resources as files in a Git repository and load them into Sommatic AI from one branch per installation. Changes travel through pull requests; Sommatic AI reads, previews and applies, and never writes to the repository.

Source: https://docs.sommatic.ai/en/git-sync/ (updated 2026-11-26)

Git Sync makes a Git repository the **source of truth** for your workflows and knowledge resources. Developers,
partner teams and coding agents change JSON files through branches and pull requests. Sommatic AI reads one branch of
that repository, shows you exactly what would change and, when you apply it, loads the result into its resources.
You get review, history and rollback from Git, and an auditable deployment in Sommatic AI.

Diagram: A change merges through a pull request; Sommatic AI previews the new head without writing and applies exactly that commit.

## What you get

- **Review before deploy.** Every change is a pull request. Sommatic AI only applies a commit you previewed.
- **One repository, many installations.** Development and production read the same files from different branches.
  Values that differ per installation (provider ids, credential ids, resource ids) live in an environment file, not
  in the workflow.
- **No secrets in Git.** Secrets are tokens that Sommatic AI resolves on the server.
- **Traceability.** Each resource records the commit it was synced from and the commit its published version comes
  from.

![Two aluminium rails merging into one at a small blue glass block](https://docs.sommatic.ai/images/docs/git-sync.webp)

## How it works

| Piece                | What it is                                                                                                                                           |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Package**          | Any folder with a `sommatic.json` manifest. It lists the workflows and knowledge resources it owns, each with a stable logical `key`.                |
| **Resource file**    | One JSON file per workflow or knowledge resource, in the studio export format plus a `sommatic` header.                                              |
| **Environment file** | `environments/<name>.json`: the branch an installation reads and the values of that installation (variables, resource ids, where to read secrets).   |
| **Tokens**           | `@@env.NAME@@`, `@@ref.<key>@@` and `@@secret.NAME@@` inside resource files. They are replaced with the environment's values when Sommatic AI syncs. |
| **Connection**       | A Git repository registered in Sommatic AI: provider, `owner/name`, branch, environment and a read-only token stored as a credential.                |

A typical repository:

```text
acme/solutions
├── support/                 # a package
│   ├── sommatic.json
│   ├── workflows/triage.json
│   └── knowledge/faq.json
└── environments/
    ├── dev.json             # branch: development
    └── prod.json            # branch: main
```

## The flow

1. You change a resource file on a `feature/*` branch and open a pull request. Checks validate the files.
2. The pull request is merged into the branch that an installation reads (for example `development` for dev).
3. In Sommatic AI you **preview** the package: it resolves the tokens with that installation's environment file and
   compares the result with what Sommatic AI has today. Preview writes nothing.
4. You **apply** exactly the commit you previewed, optionally publishing a new version.
5. The same change moves to the next branch (`qa`, then `main`) through more pull requests, and is applied in each
   installation.

> **Note: Sommatic AI only reads**
>
> Sommatic AI never pushes, commits or opens pull requests. To bring a change made in the studio into Git, export the
> resource and commit the file yourself through a pull request.

Only GitHub is implemented as a provider today, including GitHub Enterprise through the connection's base URL.

## In the portal

- **Platform infrastructure → Git repositories**: create, test and edit connections. The detail page shows the head
  commit and, per package, the status of each resource against this installation: _Up to date_, _Changes in Git_,
  _Not mapped_ or _Error_. From there you sync a package or a single resource, with optional publish.
- **Workflow studio**, menu **…** → **Sync from Git…**: preview one workflow and load its nodes into the canvas
  without saving. **Export for Git…** gives you the file, the manifest entry and the environment entry.
- **Knowledge resource editor**, menu **…** → **Sync from Git…** and **Export for Git…**.

## Next steps

- [Packages](https://docs.sommatic.ai/en/git-sync/packages.md): The sommatic.json manifest and how keys work.
- [Environments and tokens](https://docs.sommatic.ai/en/git-sync/environments-and-tokens.md): Per-installation values, resource ids and secrets.
- [Preview and apply](https://docs.sommatic.ai/en/git-sync/preview-and-apply.md): Deploy a reviewed commit with the API.
- [Playbook for coding agents](https://docs.sommatic.ai/en/git-sync/agents.md): Let an agent write workflows as files, safely.
