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

# mesa.repos.syncUpstream()

> Sync a repository upstream remote.

Enqueue a sync for the configured upstream remote.

```ts theme={null}
const run = await mesa.repos.syncUpstream({ repo: 'app', direction: 'pull' });
console.log(run.id, run.status);

await mesa.repos.syncUpstream({
  repo: 'app',
  direction: 'pull',
  ref_globs: {
    branches: 'main',
  },
});
```

## Options

<ParamField path="repo" type="string" required>
  Repository name.
</ParamField>

<ParamField path="direction" type="'pull' | 'push'" required>
  `pull` fetches from upstream into Mesa. `push` sends Mesa branches and tags to upstream.
</ParamField>

<ParamField path="ref_globs" type="{ branches?: string; tags?: string } | undefined">
  Branch and tag glob filters for this sync. Omit this field to sync all supported branches and tags. If provided, include at least one of `branches` or `tags`.
</ParamField>

<ParamField path="ref_globs.branches" type="string">
  Glob matched against upstream branch names, such as `main`, `release/*`, or `*`. Omit or use an empty string to match no branches. Do not include `refs/heads/`.
</ParamField>

<ParamField path="ref_globs.tags" type="string">
  Glob matched against upstream tag names, such as `v1.*` or `*`. Omit or use an empty string to match no tags. Do not include `refs/tags/`.
</ParamField>

<ParamField path="org" type="string | undefined">
  Organization override.
</ParamField>

## Response

Returns a sync object with fields such as `id`, `repo_id`, `direction`, `status`, `attempt`, `ref_globs`, `stats`, `error`, `created_at`, `started_at`, and `finished_at`.

`ref_globs` is returned as normalized branch and tag glob filters. `stats.refs` contains only source refs that matched the filters.

## Required scope

`write`
