use_github() takes a local project, creates an associated repo on GitHub, adds it to your local repo as the origin remote, and makes an initial push to synchronize. use_github() requires that your project already be a Git repository, which you can accomplish with use_git(), if needed. See the Authentication section below for other necessary setup.

use_github(
  organisation = NULL,
  private = FALSE,
  protocol = git_protocol(),
  credentials = NULL,
  auth_token = github_token(),
  host = NULL
)

Arguments

organisation

If supplied, the repo will be created under this organisation, instead of the account of the user associated with the auth_token. You must have permission to create repositories.

private

If TRUE, creates a private repository.

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

A git2r credential object produced with git2r::cred_env(), git2r::cred_ssh_key(), git2r::cred_token(), or git2r::cred_user_pass().

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".

Authentication

A new GitHub repo will be created via the GitHub API, therefore you must make a GitHub personal access token (PAT) available. You can either provide this directly via the auth_token argument or store it for retrieval with github_token().

Examples

if (FALSE) { pkgpath <- file.path(tempdir(), "testpkg") create_package(pkgpath) # creates package below temp directory proj_set(pkgpath) ## now, working inside "testpkg", initialize git repository use_git() ## create github repository and configure as git remote use_github() }