use_github {usethis}R Documentation

Connect a local repo with GitHub

Description

use_github() takes a local project and:

See below for the authentication setup that is necessary for all of this to work.

Usage

use_github(
  organisation = NULL,
  private = FALSE,
  visibility = c("public", "private", "internal"),
  protocol = git_protocol(),
  host = NULL,
  auth_token = deprecated(),
  credentials = deprecated()
)

Arguments

organisation

If supplied, the repo will be created under this organisation, instead of the login associated with the GitHub token discovered for this host. The user's role and the token's scopes must be such that you have permission to create repositories in this organisation.

private

If TRUE, creates a private repository.

visibility

Only relevant for organisation-owned repos associated with certain GitHub Enterprise products. The special "internal" visibility grants read permission to all organisation members, i.e. it's intermediate between "private" and "public", within GHE. When specified, visibility takes precedence over private = TRUE/FALSE.

protocol

One of "https" or "ssh"

host

GitHub host to target, passed to the .api_url argument of gh::gh(). If unspecified, gh defaults to "https://api.github.com", although gh's default can be customised by setting the GITHUB_API_URL environment variable.

For a hypothetical GitHub Enterprise instance, either "https://github.acme.com/api/v3" or "https://github.acme.com" is acceptable.

auth_token, credentials

[Deprecated]: No longer consulted now that usethis uses the gert package for Git operations, instead of git2r; gert relies on the credentials package for auth. The API requests are now authorized with the token associated with the host, as retrieved by gh::gh_token().

Git/GitHub Authentication

Many usethis functions, including those documented here, potentially interact with GitHub in two different ways:

Therefore two types of auth can happen and your credentials must be discoverable. Which credentials do we mean?

Git/GitHub credential management is covered in a dedicated article: Managing Git(Hub) Credentials

Examples

## Not run: 
pkgpath <- file.path(tempdir(), "testpkg")
create_package(pkgpath)

## now, working inside "testpkg", initialize git repository
use_git()

## create github repository and configure as git remote
use_github()

## End(Not run)

[Package usethis version 2.2.3 Index]