Description Usage Arguments Details Value Examples
This function deletes a file in a repository in GitHub by creating a new
commit on the specified branch. If the branch does not already exist a
parent
commit must be specified and a new branch is created from it. If the
file does not exist delete_file()
throws as error.
1 | delete_file(path, branch, message, repo, parent, author, committer, ...)
|
path |
(string) The path of the file to delete, within the repository. |
branch |
(string) The name of the branch to make the new commit on. |
message |
(string) The commit message. |
repo |
(string) The repository specified in the format: |
parent |
(string, optional) If creating a new branch the the parent commit must be specified as either a SHA, branch or tag. |
author |
(list, optional) A the name and email address of the user who wrote the changes in the commit. |
committer |
(list, optional) A the name and email address of the user who created the commit. |
... |
Parameters passed to |
The author
and committer
arguments are optional and if not supplied the
current authenticated user is used. However, if you want to set them
explicitly you must specify a named list with name
and email
as the
elements (see examples).
Note: The GitHub API imposes a file size limit of 1MB for this request. For
larger files use the upload_files()
function.
For more details see the GitHub API documentation:
delete_file()
returns a list of the commit properties.
Commit Properties:
sha: The commit SHA.
message: The commit message.
author_name: The author's name.
author_email: The author's email address.
committer_name: The committer's name.
committer_email: The committer's email address.
tree_sha: The SHA of the file tree.
parent_sha: The commit SHA of the parent(s).
date: The date the commit was made.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## Not run:
# Delete a file on the main branch
delete_file(
path = "file-to-delete.md",
branch = "main",
message = "Deleted a file with delete_file()",
repo = "ChadGoymer/githapi"
)
# Delete a file on a new branch
create_file(
path = "file-to-delete.md",
branch = "new-branch",
message = "Deleted a file with delete_file()",
repo = "ChadGoymer/githapi",
parent = "main"
)
# Delete a file on the main branch specifying an author and committer
delete_file(
path = "file-to-delete.md",
branch = "main",
message = "Deleted a file with delete_file()",
repo = "ChadGoymer/githapi",
author = list(name = "Bob", email = "bob@acme.com"),
committer = list(name = "Jane", email = "jane@acme.com")
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.