---
title: "Update a reference"
method: PATCH
path: "/repos/{owner}/{repo}/git/refs/{ref}"
tags: ["git"]
---

# Update a reference

`PATCH /repos/{owner}/{repo}/git/refs/{ref}`

Updates the provided reference to point to a new SHA. For more information, see "[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)" in the Git documentation.

## Path parameters

- `owner` string, required
- `repo` string, required
- `ref` string, required

## Request body

- object
  - `sha` string, required — The SHA1 value to set this reference to
  - `force` boolean — Indicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to `false` will make sure you're not overwriting work.

## Response `200`

Response

- GitRef — Git references within a repository
  - `ref` string, required
  - `node_id` string, required
  - `url` string, uri, required
  - `object` object, required
    - `type` string, required
    - `sha` string, required — SHA for the reference
    - `url` string, uri, required

## Other responses

- `409` — Conflict
- `422` — Validation failed, or the endpoint has been spammed.

---

[API](https://skmtc.net/github/apis/rest-api.md) · [All operations](https://skmtc.net/github/apis/rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/rest-api/versions/80850db290cd/schema)
