跳转到内容
Try Gitea Cloud ☁️ for 30 days → Accelerate your Development & Deploys!
Support
This is the documentation of 22.6.1, which is no longer the latest release. See the latest release.

Delete a file in a repository

DELETE
/repos/{owner}/{repo}/contents/{filepath}
curl --request DELETE \
--url https://gitea.example.com/api/v1/repos/example/example/contents/example \
--header 'Authorization: Basic <credentials>' \
--header 'Content-Type: application/json' \
--data '{ "author": { "email": "hello@example.com", "name": "example" }, "branch": "example", "committer": { "email": "hello@example.com", "name": "example" }, "dates": { "author": "2026-04-15T12:00:00Z", "committer": "2026-04-15T12:00:00Z" }, "message": "example", "new_branch": "example", "sha": "example", "signoff": true }'
owner
required
string

Owner of the repo

repo
required
string

Name of the repo

filepath
required
string

Path of the file to delete

Media typeapplication/json

DeleteFileOptions options for deleting files (used for other File structs below) Note: author and committer are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)

object
author

Identity for a person’s identity like an author or committer

object
email
string format: email
name
string
branch

Branch (optional) to base this file from. if not given, the default branch is used

string
committer

Identity for a person’s identity like an author or committer

object
email
string format: email
name
string
dates

CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE

object
author
string format: date-time
committer
string format: date-time
message

Message (optional) for the commit of this file. if not supplied, a default message will be used

string
new_branch

New_branch (optional) will make a new branch from branch before creating the file

string
sha
required

Sha is the SHA for the file that already exists

string
signoff

Add a Signed-off-by trailer by the committer at the end of the commit log message.

boolean
Examplegenerated
{
"author": {
"email": "hello@example.com",
"name": "example"
},
"branch": "example",
"committer": {
"email": "hello@example.com",
"name": "example"
},
"dates": {
"author": "2026-04-15T12:00:00Z",
"committer": "2026-04-15T12:00:00Z"
},
"message": "example",
"new_branch": "example",
"sha": "example",
"signoff": true
}

FileDeleteResponse

Media typeapplication/json

FileDeleteResponse contains information about a repo’s file that was deleted

object
commit
FileCommitResponse contains information generated from a Git commit for a repo's file.
object
author
CommitUser contains information of a user in the context of a commit.
object
date
string
email
string format: email
name
string
committer
CommitUser contains information of a user in the context of a commit.
object
date
string
email
string format: email
name
string
created
string format: date-time
html_url
string
message
string
parents
Array<object>
CommitMeta contains meta information of a commit in terms of API.
object
created
string format: date-time
sha
string
url
string
sha
string
tree
CommitMeta contains meta information of a commit in terms of API.
object
created
string format: date-time
sha
string
url
string
url
string
content
verification

PayloadCommitVerification represents the GPG verification of a commit

object
payload
string
reason
string
signature
string
signer

PayloadUser represents the author or committer of a commit

object
email
string format: email
name

Full name of the commit author

string
username
string
verified
boolean
Examplegenerated
{
"commit": {
"author": {
"date": "example",
"email": "hello@example.com",
"name": "example"
},
"committer": {
"date": "example",
"email": "hello@example.com",
"name": "example"
},
"created": "2026-04-15T12:00:00Z",
"html_url": "example",
"message": "example",
"parents": [
{
"created": "2026-04-15T12:00:00Z",
"sha": "example",
"url": "example"
}
],
"sha": "example",
"tree": {
"created": "2026-04-15T12:00:00Z",
"sha": "example",
"url": "example"
},
"url": "example"
},
"content": "example",
"verification": {
"payload": "example",
"reason": "example",
"signature": "example",
"signer": {
"email": "hello@example.com",
"name": "example",
"username": "example"
},
"verified": true
}
}

APIError is error format response

Media typeapplication/json
message
string
url
string

APIError is error format response

Media typeapplication/json
message
string
url
string

APIError is error format response

Media typeapplication/json
message
string
url
string

APIRepoArchivedError is an error that is raised when an archived repo should be modified

Media typeapplication/json
message
string
url
string