Skip to content

Delete a file

DELETE
/repos/{owner}/{repo}/contents/{path}

Deletes a file in a repository.

You can provide an additional committer parameter, which is an object containing information about the committer. Or, you can provide an author parameter, which is an object containing information about the author.

The author section is optional and is filled in with the committer information if omitted. If the committer information is omitted, the authenticated user’s information is used.

You must provide values for both name and email, whether you choose to use author or committer. Otherwise, you’ll receive a 422 status code.

[!NOTE] If you use this endpoint and the “Create or update file contents” endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.

API method documentation

owner
required
string

The account owner of the repository. The name is not case sensitive.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

path
required
string

Path parameter

Media type application/json
object
message
required

The commit message.

string
sha
required

The blob SHA of the file being deleted.

string
branch

The branch name. Default: the repository’s default branch

string
committer

Object containing information about the committer.

object
name

The name of the author (or committer) of the commit

string
email

The email of the author (or committer) of the commit

string
author

Object containing information about the author.

object
name

The name of the author (or committer) of the commit

string
email

The email of the author (or committer) of the commit

string
Examples
Example default
{
"message": "my commit message",
"committer": {
"name": "Monalisa Octocat",
"email": "octocat@github.com"
},
"sha": "329688480d39049927147c162b9d2deaf885005f"
}

Response

Media type application/json
File Commit

File Commit

object
content
required
object
name
string
path
string
sha
string
size
integer
url
string
html_url
string
git_url
string
download_url
string
type
string
_links
object
self
string
git
string
html
string
commit
required
object
sha
string
node_id
string
url
string
html_url
string
author
object
date
string
name
string
email
string
committer
object
date
string
name
string
email
string
message
string
tree
object
url
string
sha
string
parents
Array<object>
object
url
string
html_url
string
sha
string
verification
object
verified
boolean
reason
string
signature
string
nullable
payload
string
nullable
verified_at
string
nullable
Examples
Example default
{
"content": null,
"commit": {
"sha": "7638417db6d59f3c431d3e1f261cc637155684cd",
"node_id": "MDY6Q29tbWl0NzYzODQxN2RiNmQ1OWYzYzQzMWQzZTFmMjYxY2M2MzcxNTU2ODRjZA==",
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
"html_url": "https://github.com/octocat/Hello-World/git/commit/7638417db6d59f3c431d3e1f261cc637155684cd",
"author": {
"date": "2014-11-07T22:01:45Z",
"name": "Monalisa Octocat",
"email": "octocat@github.com"
},
"committer": {
"date": "2014-11-07T22:01:45Z",
"name": "Monalisa Octocat",
"email": "octocat@github.com"
},
"message": "my commit message",
"tree": {
"url": "https://api.github.com/repos/octocat/Hello-World/git/trees/691272480426f78a0138979dd3ce63b77f706feb",
"sha": "691272480426f78a0138979dd3ce63b77f706feb"
},
"parents": [
{
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/1acc419d4d6a9ce985db7be48c6349a0475975b5",
"html_url": "https://github.com/octocat/Hello-World/git/commit/1acc419d4d6a9ce985db7be48c6349a0475975b5",
"sha": "1acc419d4d6a9ce985db7be48c6349a0475975b5"
}
],
"verification": {
"verified": false,
"reason": "unsigned",
"signature": null,
"payload": null,
"verified_at": null
}
}
}

Resource not found

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Conflict

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Validation failed, or the endpoint has been spammed.

Media type application/json
Validation Error

Validation Error

object
message
required
string
documentation_url
required
string
errors
Array<object>
object
resource
string
field
string
message
string
code
required
string
index
integer
value
One of:
string
nullable
Example generated
{
"message": "example",
"documentation_url": "example",
"errors": [
{
"resource": "example",
"field": "example",
"message": "example",
"code": "example",
"index": 1,
"value": [
"example"
]
}
]
}

Service unavailable

Media type application/json
object
code
string
message
string
documentation_url
string
Example generated
{
"code": "example",
"message": "example",
"documentation_url": "example"
}