# Update a reference

From **GitHub v3 REST API**.

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

Update a reference

## Parameters

### `owner`

- Location: path
- Required: true
- Type: `string`

### `repo`

- Location: path
- Required: true
- Type: `string`

### `ref`

- Location: path
- Required: true
- Type: `string`

ref parameter

## Request body

- Required: true
### `application/json`

- Type: `object`

```json
{
  "force": true,
  "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd"
}
```

```json
{"properties":{"force":{"default":false,"description":"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.","type":"boolean"},"sha":{"description":"The SHA1 value to set this reference to","type":"string"}},"required":["sha"],"type":"object"}
```

## Responses

### `200`

Response

### `application/json`

- Type: `object`

Git references within a repository

```json
{
  "node_id": "MDM6UmVmcmVmcy9oZWFkcy9mZWF0dXJlQQ==",
  "object": {
    "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
    "type": "commit",
    "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
  },
  "ref": "refs/heads/featureA",
  "url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/featureA"
}
```

```json
{"description":"Git references within a repository","properties":{"node_id":{"type":"string"},"object":{"properties":{"sha":{"description":"SHA for the reference","example":"7638417db6d59f3c431d3e1f261cc637155684cd","maxLength":40,"minLength":40,"type":"string"},"type":{"type":"string"},"url":{"format":"uri","type":"string"}},"required":["type","sha","url"],"type":"object"},"ref":{"type":"string"},"url":{"format":"uri","type":"string"}},"required":["ref","node_id","url","object"],"title":"Git Reference","type":"object"}
```

### `422`

Validation failed

### `application/json`

- Type: `object`

Validation Error

```json
{"description":"Validation Error","properties":{"documentation_url":{"type":"string"},"errors":{"items":{"properties":{"code":{"type":"string"},"field":{"type":"string"},"index":{"type":"integer"},"message":{"type":"string"},"resource":{"type":"string"},"value":{"oneOf":[{"nullable":true,"type":"string"},{"nullable":true,"type":"integer"},{"items":{"type":"string"},"nullable":true,"type":"array"}]}},"required":["code"],"type":"object"},"type":"array"},"message":{"type":"string"}},"required":["message","documentation_url"],"title":"Validation Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request PATCH \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/git/refs/{ref} \
  --header 'content-type: application/json' \
  --data '{
  "force": true,
  "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd"
}'
```
