# Get a reference

From **GitHub v3 REST API**.

`GET /repos/{owner}/{repo}/git/ref/{ref}`

Returns a single reference from your Git database. The `:ref` in the URL must be formatted as `heads/<branch name>` for branches and `tags/<tag name>` for tags. If the `:ref` doesn't match an existing ref, a `404` is returned.

**Note:** You need to explicitly [request a pull request](https://docs.github.com/enterprise-server@3.0/rest/reference/pulls#get-a-pull-request) to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "[Checking mergeability of pull requests](https://docs.github.com/enterprise-server@3.0/rest/guides/getting-started-with-the-git-database-api#checking-mergeability-of-pull-requests)".

## Parameters

### `owner`

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

### `repo`

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

### `ref`

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

ref parameter

## 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"}
```

### `404`

Resource not found

### `application/json`

- Type: `object`

Basic Error

```json
{"description":"Basic Error","properties":{"documentation_url":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"}},"title":"Basic Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request GET \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/git/ref/{ref}
```
