Learn R Programming

usethis (version 1.5.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_token(). 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_spec, destdir = NULL, fork = NA,
  rstudio = NULL, open = interactive(), protocol = git_protocol(),
  credentials = NULL, auth_token = github_token(), host = NULL)

Arguments

repo_spec

GitHub repo specification in this form: owner/repo. The repo 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_spec itself. Will be set to FALSE if no auth_token (a.k.a. PAT) is provided or preconfigured. Otherwise, defaults to FALSE if you can push to repo_spec and TRUE if you cannot. In the case of a fork, the original target repo is added to the local repo as the upstream remote, using the preferred protocol. The master branch is immediately pulled from upstream, which matters in the case of a pre-existing, out-of-date fork.

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, activates the new project:

  • If RStudio desktop, the package is opened in a new session.

  • If on RStudio server, the current RStudio project is activated.

  • Otherwise, the working directory and active project is changed.

protocol

Optional. Should be "ssh" or "https", if specified. Defaults to the option usethis.protocol and, if unset, to an interactive choice or, in non-interactive sessions, "ssh". NA triggers the interactive menu.

credentials
auth_token

GitHub personal access token (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_github() for GitHub setup advice. git_protocol() and git_credentials() for background on protocol and credentials. 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