fetch | R Documentation |
Fetch new data and update tips
fetch(
repo = ".",
name = NULL,
credentials = NULL,
verbose = TRUE,
refspec = NULL
)
repo |
a path to a repository or a |
name |
the remote's name |
credentials |
The credentials for remote repository access. Default is NULL. To use and query an ssh-agent for the ssh key credentials, let this parameter be NULL (the default). |
verbose |
Print information each time a reference is updated
locally. Default is |
refspec |
The refs to fetch and which local refs to update,
see examples. Pass NULL to use the
|
invisible list of class git_transfer_progress
with statistics from the fetch operation:
Number of objects in the packfile being downloaded
Received objects that have been hashed
Objects which have been downloaded
Total number of deltas in the pack
Deltas which have been indexed
Locally-available objects that have been injected in order to fix a thin pack
Size of the packfile received up to now
## Not run:
## Initialize three temporary repositories
path_bare <- tempfile(pattern="git2r-")
path_repo_1 <- tempfile(pattern="git2r-")
path_repo_2 <- tempfile(pattern="git2r-")
dir.create(path_bare)
dir.create(path_repo_1)
dir.create(path_repo_2)
bare_repo <- init(path_bare, bare = TRUE)
repo_1 <- clone(path_bare, path_repo_1)
repo_2 <- clone(path_bare, path_repo_2)
config(repo_1, user.name = "Alice", user.email = "alice@example.org")
config(repo_2, user.name = "Bob", user.email = "bob@example.org")
## Add changes to repo 1
writeLines("Lorem ipsum dolor sit amet",
con = file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "Commit message")
## Push changes from repo 1 to origin (bare_repo)
push(repo_1, "origin", "refs/heads/master")
## Fetch changes from origin (bare_repo) to repo 2
fetch(repo_2, "origin")
## List updated heads
fetch_heads(repo_2)
## Checking out GitHub pull requests locally
path <- tempfile(pattern="ghit-")
repo <- clone("https://github.com/leeper/ghit", path)
fetch(repo, "origin", refspec = "pull/13/head:refs/heads/BRANCHNAME")
checkout(repo, "BRANCHNAME")
summary(repo)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.