---
title: "Create a reference"
method: POST
path: "/repos/{owner}/{repo}/git/refs"
tags: ["git"]
---

# Create a reference

`POST /repos/{owner}/{repo}/git/refs`

Creates a reference for your repository. You are unable to create new references for empty repositories, even if the commit SHA-1 hash used exists. Empty repositories are repositories without branches.

## Path parameters

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

## Request body

- object
  - `ref` string, required — The name of the fully qualified reference (ie: `refs/heads/master`). If it doesn't start with 'refs' and have at least two slashes, it will be rejected.
  - `sha` string, required — The SHA1 value for this reference.

## Response `201`

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/github-v3-rest-api-3.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-3/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-3/versions/dc0584ac4e13/schema)
