Creates a new local Git repository from a repository on GitHub. It is highly
recommended that you pre-configure or pass a GitHub personal access token
(PAT), which is facilitated by browse_github_pat()
. In particular, a PAT is
required in order for create_from_github()
to do "fork and clone". It is also required
by use_github()
, which connects existing local projects to GitHub.
create_from_github(repo, destdir = NULL, fork = NA, rstudio = NULL,
open = interactive(), protocol = c("ssh", "https"), credentials = NULL,
auth_token = NULL, host = NULL)
GitHub repo specification in this form: owner/reponame
. The
second part will be the name of the new local repo.
The new folder is stored here. Defaults to user's Desktop.
If TRUE
, we create and clone a fork. If FALSE
, we clone
repo
itself. Will be set to FALSE
if no auth_token
(a.k.a. PAT) is
provided or preconfigured. Otherwise, if unspecified, defaults to FALSE
if you can push to repo
and TRUE
if you cannot. If a fork is created,
the original target repo is added to the local repo as the upstream
remote, using your preferred protocol
, to make it easier to pull upstream
changes in the future.
Initiate an RStudio Project?
Defaults to TRUE
if in an RStudio session and project has no
pre-existing .Rproj
file. Defaults to FALSE
otherwise.
If TRUE
and in RStudio, the new project is opened in a new
instance, if possible, or is switched to, otherwise. If TRUE
and not
in RStudio, working directory is set to the new project.
transfer protocol, either "ssh" (the default) or "https"
A git2r::cred_ssh_key()
specifying specific ssh
credentials or NULL
for default ssh key and ssh-agent behaviour.
Provide a personal access token (PAT) from
https://github.com/settings/tokens. If NULL
, will use the logic
described in gh::gh_whoami()
to look for a token stored in an environment
variable. Use browse_github_pat()
to help set up your PAT.
GitHub API host to use. Override with the endpoint-root for your GitHub enterprise instance, for example, "https://github.hostname.com/api/v3"
use_course()
for one-time download of all files in a Git repo,
without any local or remote Git operations.
# NOT RUN {
create_from_github("r-lib/usethis")
# }
Run the code above in your browser using DataLab