# Update

Launch stage: GA

`PATCH /api/2.0/repos/{id}`

Updates the repo to a different branch or tag, or updates the repo to the latest commit on
 the same branch.

API scopes: workspace

## Path parameters

- `id` (int64, optional)
  ID of the Git folder (repo) object in the workspace.
  Example: `5249608814509279`

## Request body

- `branch` (string, optional)
  Branch that the local version of the repo is checked out to.
  Example: `main`
- `tag` (string, optional)
  Tag that the local version of the repo is checked out to. Updating the repo to a tag puts
   the repo in a detached HEAD state. Before committing new changes, you must update the repo to
   a branch instead of the detached HEAD.
  Example: `v1.0`
- `sparse_checkout` (object, optional)
  If specified, update the sparse checkout settings. The update will fail if sparse checkout is
   not enabled for the repo.
  - `patterns` (array of string, optional)
    List of sparse checkout cone patterns, see
     [cone mode handling](https://git-scm.com/docs/git-sparse-checkout#_internalscone_mode_handling)
     for details.
- `dangerously_force_discard_all` (boolean, optional, Beta)
  WARNING: DESTRUCTIVE AND IRREVERSIBLE. If true, permanently deletes ALL uncommitted
   changes in the Git folder — staged, unstaged, and untracked files — before updating.
   Lost data CANNOT be recovered.
  
   NEVER use this on Git folders where users author or edit files. This flag is intended
   ONLY for automated jobs that treat the Git folder as a read-only mirror of a remote
   branch and need to force-sync it. If any user has uncommitted work in the Git folder,
   that work will be permanently destroyed without warning.
  
   Local commits that have been made but not yet pushed to the remote are preserved.
- `git_credential_id` (int64, optional)
  Git credential ID to use for this update operation. The Git credential must be
   configured for the current user.

## Request

```json
{
  "branch": "main",
  "sparse_checkout": {
    "patterns": [
      "parent-folder/child-folder",
      "src",
      "test"
    ]
  }
}
```

## Response

### The Git folder (repo) was successfully updated.

```json
{}
```

