Learn R Programming

workflowr (version 0.7.0)

wflow_remotes: Manage remote Git repositories.

Description

wflow_remotes is a convenience function for managing remote repositories from R. By default is displays the current remote repositories (analogous to git remote -v). It can add a remote, remove a remote, or update the URL for an existing remote.

Usage

wflow_remotes(remote = NULL, user = NULL, repo = NULL,
  protocol = "https", action = "add", verbose = TRUE, project = ".")

Arguments

remote

character (default: NULL). The name of the remote.

user

character (default: NULL). The GitHub username for the remote repository.

repo

character (default: NULL). The name of the remote repository on GitHub.

protocol

character (default: "https"). The protocol for communicating with GitHub. Must be either "https" or "ssh".

action

character (default: "add"). The action to perform on the remotes. Must be one of "add", "remove", or "set_url". This argument is ignored if remote = NULL.

verbose

logical (default: TRUE). Display the current remotes. Analogous to git remote -v.

project

character (default: ".") By default the function assumes the current working directory is within the project. If this is not true, you'll need to provide the path to the project directory.

Value

Invisibly returns a named character vector of the remote URLs.

Details

wflow_remotes constructs a URL to a remote GitHub repository based on the input GitHub username, GitHub repository name, and protocol (https or ssh). It can add a remote (action = "add"), remove a remote (action = "remove"), or update the URL for an existing remote (action = "set_url").

This function cannot change the name of an existing remote. To accomplish this, you could run Git from the command line (git remote rename <old> <new>) or use git2r::remote_rename from R.

Examples

Run this code
# NOT RUN {
# Display the current remotes
wflow_remotes()
# Add a remote called origin that points to the
# GitHub repository example_repo owned by
# the GitHub user example_user
wflow_remotes("origin", "example_user", "example_repo")
# Remove the remote named upstream
wflow_remotes("upstream", action = "remove")
# Change the protocol of the remote origin from https to ssh
wflow_remotes("origin", "example_user", "example_repo", protocol = "ssh",
              action = "set_url")
# }

Run the code above in your browser using DataLab