usethis (version 1.3.0)

create_from_github: Create a project from a GitHub repo

Description

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.

Usage

create_from_github(repo, destdir = NULL, fork = NA, rstudio = NULL,
  open = interactive(), protocol = c("ssh", "https"), credentials = NULL,
  auth_token = NULL, host = NULL)

Arguments

repo

GitHub repo specification in this form: owner/reponame. The second part will be the name of the new local repo.

destdir

The new folder is stored here. Defaults to user's Desktop.

fork

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.

rstudio

Initiate an RStudio Project? Defaults to TRUE if in an RStudio session and project has no pre-existing .Rproj file. Defaults to FALSE otherwise.

open

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.

protocol

transfer protocol, either "ssh" (the default) or "https"

credentials

A git2r::cred_ssh_key() specifying specific ssh credentials or NULL for default ssh key and ssh-agent behaviour.

auth_token

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.

host

GitHub API host to use. Override with the endpoint-root for your GitHub enterprise instance, for example, "https://github.hostname.com/api/v3"

See Also

use_course() for one-time download of all files in a Git repo, without any local or remote Git operations.

Examples

Run this code
# NOT RUN {
create_from_github("r-lib/usethis")
# }

Run the code above in your browser using DataLab