git_ssh: Switch between ssh authentication and ssl authentication for...

View source: R/functions.R

git_sshR Documentation

Switch between ssh authentication and ssl authentication for a git repo.

Description

A use-case for this is some environments that by default initialize projects as ssl/https (e.g. RStudio Cloud) but some users may prefer ssh authentication. This easily converts between the two settings without having to remember the whole git command. Will silently return errors from shell but will not throw an error.

Usage

git_ssh(
  tossh = TRUE,
  sshstr = "git@github.com:",
  sslstr = "https://github.com/"
)

Arguments

tossh

If 'TRUE', will attempt to convert the remote.origin.url from https to ssh. Default: 'TRUE'

sshstr

A string to use as the prefix for ssh connection. Optional, defaults to the values used by github.com

sslstr

A string to use as the prefix for the ssl connection. Optional, defaults to the values used by github.com.

Value

Invisibly returns '0' or an error code.

Examples

## Not run: 
# Convert from https://github.com/... to git@github.com:...
git_ssh()

# Convert from git@github.com:... to https://github.com/...
git_ssh(FALSE)


## End(Not run)

bokov/tidbits documentation built on Jan. 26, 2024, 6:25 p.m.