wflow_git_remote
is a convenience function for managing remote
repositories from R. By default it 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.
wflow_git_remote( remote = NULL, user = NULL, repo = NULL, protocol = "https", action = "add", domain = "github.com", verbose = TRUE, project = "." )
remote | character (default: NULL). The name of the remote. |
---|---|
user | character (default: NULL). The username for the remote repository. |
repo | character (default: NULL). The name of the remote repository on the Git hosting service (e.g. GitHub or GitLab). |
protocol | character (default: "https"). The protocol for communicating with the Git hosting service (e.g. GitHub or GitLab). 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 |
domain | character (default: "github.com"). The domain of the remote host. For example, if you want to host your Git repository at GitLab, you would specify "gitlab.com". |
verbose | logical (default: TRUE). Display the current remotes.
Analogous to |
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. |
Invisibly returns a named character vector of the remote URLs.
wflow_git_remote
constructs a URL to a remote repository based on the
input username, repository name, protocol (https or ssh), and domain (e.g.
"github.com" or "gitlab.com"). 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 Terminal (git remote rename <old>
<new>
) or use git2r::remote_rename
from R.
if (FALSE) { # Display the current remotes wflow_git_remote() # Add a remote called origin that points to the # GitHub repository example_repo owned by # the GitHub user example_user wflow_git_remote("origin", "example_user", "example_repo") # Remove the remote named upstream wflow_git_remote("upstream", action = "remove") # Change the protocol of the remote origin from https to ssh wflow_git_remote("origin", "example_user", "example_repo", protocol = "ssh", action = "set_url") # Add a remote called origin that points to the # GitLab repository example_repo owned by # the GitLab user example_user wflow_git_remote("origin", "example_user", "example_repo", domain = "gitlab.com") }