use_github: Connect a local repo with GitHub

Description Usage Arguments Git/GitHub Authentication Examples

View source: R/github.R

Description

use_github() takes a local project and:

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

Usage

1
2
3
4
5
6
7
8
use_github(
  organisation = NULL,
  private = FALSE,
  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.

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 lifecycle: 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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)

usethis documentation built on Feb. 10, 2021, 5:08 p.m.