Description Usage Arguments Details Value Examples
This function uploads all the files in the directory (except those in the
ignore
argument) and creates a new commit on the specified branch. Note:
the new commit is created with exactly the files uploaded, so if a file in
the parent commit has not been uploaded it will be removed in the new commit.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
path |
(string) The path to the directory to upload. It must be readable. |
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: |
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. |
parents |
(character, optional) References for the commits to use as parents, can be either a SHA, branch or tag. If it is a branch then the head commit is used. See the details section for more information. |
ignore |
(character, optional) The files to ignore in the directory.
Default: |
force |
(boolean, optional) Whether to force the update if it is not a
simple fast-forward. Default: |
... |
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).
A commit may have none, one or two parents. If none are specified and the
branch already exists, the head of the branch will be used as a parent. If
the branch does not exist, an orphan commit is created without a parent. If
one parent is specified the commit is added and the branch set to the new
commit, if it is a simple fast-forward. If you want to set the branch to the
new commit no matter what then set the force
argument to TRUE
. If two
parents are specified then a merge commit is created.
For more details see the GitHub API documentation:
upload_commit()
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | ## Not run:
# Add a commit to the main branch
upload_commit(
path = "C:/files-to-upload",
branch = "main",
message = "Commit to test upload_commit()",
repo = "ChadGoymer/githapi"
)
# override the author and committer
upload_commit(
path = "C:/files-to-upload",
branch = "main",
message = "Commit to test upload_commit()",
repo = "ChadGoymer/githapi",
author = list(name = "Bob", email = "bob@acme.com"),
committer = list(name = "Jane", email = "jane@acme.com")
)
# Create a commit on a new branch
upload_commit(
path = "C:/files-to-upload",
branch = "test-commits-1",
message = "Commit to test upload_commit()",
repo = "ChadGoymer/githapi",
parents = "main"
)
# Create an orphan commit
upload_commit(
path = "C:/files-to-upload",
branch = "test-commits-2",
message = "Commit to test upload_commit()",
repo = "ChadGoymer/githapi"
)
# Force branch to point at the new commit
upload_commit(
path = "C:/files-to-upload",
branch = "main",
message = "Commit to test upload_commit()",
repo = "ChadGoymer/githapi",
parents = "test-commits-1",
force = TRUE
)
# Create a commit merging a branch into the main branch
upload_commit(
path = "C:/files-to-upload",
branch = "main",
message = "Commit to test upload_commit()",
repo = "ChadGoymer/githapi",
parents = c("main", "test-commits-1")
)
# Create a commit merging two branches into a new branch
upload_commit(
path = "C:/files-to-upload",
branch = "test-commits-3",
message = "Commit to test upload_commit()",
repo = "ChadGoymer/githapi",
parents = c("main", "test-commits-2")
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.