GitLab API

GitlabTool

Actions1095

Projects → deleteApiV4ProjectsIdRepositoryFilesFilePath

AI-generated

Summary

Delete a file from a specified GitLab project repository branch by providing the file path and commit details.

Inputs

  • id (required) — The project ID, can be either the numeric ID or URL-encoded path of the project, e.g., 'gitlab-org/gitlab'.
  • file_path (required) — The URL-encoded path to the file within the repository to delete, e.g., 'lib%2Fclass%2Erb'.
  • branch (required) — The name of the branch where the file will be deleted.
  • commit_message (required) — Commit message describing the deletion.
  • start_branch — For creating a new branch from this branch before committing the deletion.
  • author_email — The email address of the commit author.
  • author_name — The name of the commit author.

Output shape

a JSON object representing the result of the file deletion commit, as returned by the GitLab API; typically includes commit metadata.

Requires authentication via the configured GitLab API credentials unless 'Skip Authentication' is set. The operation corresponds to an HTTP DELETE request on endpoint /api/v4/projects/{id}/repository/files/{file_path} with query parameters for branch, commit message, and optional author and branch details.

Examples

Example 1: Deleting a file called 'README.md' from the 'main' branch of project 'gitlab-org/gitlab' with a commit message.

Set 'id' to 'gitlab-org/gitlab', 'file_path' to 'README.md' (URL-encoded as needed), 'branch' to 'main', and 'commit_message' to describe the deletion.

Links

Discussion