addRemote - Add new remote to Git repository - MATLAB (original) (raw)

Add new remote to Git repository

Since R2025a

Syntax

Description

[remoteDetails](#mw%5Fee65d97f-5487-4f0a-b6ad-05543ea19efc) = addRemote([repo](#mw%5Frem1dda80e-6e31-4fbb-95f6-4da470a4905bote%5Fsep%5Fmw%5F51431669-da82-405d-b33d-f5d5d0c7e853),[URL](#mw%5Frem1dda80e-6e31-4fbb-95f6-4da470a4905bote%5Fsep%5Fmw%5F076e1e3a-7a3f-4f61-bd75-9e5724d6e5eb)) adds a new remote specified by URL to the Gitâ„¢ repository repo.

example

[remoteDetails](#mw%5Fee65d97f-5487-4f0a-b6ad-05543ea19efc) = addRemote([repo](#mw%5Frem1dda80e-6e31-4fbb-95f6-4da470a4905bote%5Fsep%5Fmw%5F51431669-da82-405d-b33d-f5d5d0c7e853),[URL](#mw%5Frem1dda80e-6e31-4fbb-95f6-4da470a4905bote%5Fsep%5Fmw%5F076e1e3a-7a3f-4f61-bd75-9e5724d6e5eb),[Name=Value](#namevaluepairarguments)) specifies additional options as one or more name-value arguments. Use this syntax to add a remote name and a different push URL.

example

Examples

collapse all

Navigate to your repository folder and create a repository object.

Add a new remote.

remoteDetails = addRemote(repo,"https://github.com/my/remote/repo")

remoteDetails =

GitRemote with properties:

   Name: "origin"
    URL: "https://github.com/my/remote/repo"
PushURL: "https://github.com/my/remote/repo"

Navigate to your repository folder and create a repository object.

Add a named remote.

remoteDetails = addRemote(repo,"https://github.com/my/remote/repo",... Name="fork")

remoteDetails =

GitRemote with properties:

   Name: "fork"
    URL: "https://github.com/my/remote/repo"
PushURL: "https://github.com/my/remote/repo"

Navigate to your repository folder and create a repository object.

Add a remote with a different push URL.

remoteDetails = addRemote(repo,"https://github.com/my/internal/url",... PushURL="https://github.com/my/public/url")

remoteDetails =

GitRemote with properties:

   Name: "origin"
    URL: "https://github.com/my/internal/url"
PushURL: "https://github.com/my/public/url"

Input Arguments

collapse all

URL of the remote repository, specified as a string scalar or a character vector.

Example: "https://github.com/my/repo"

Data Types: char | string

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: remote=addRemote(repo,"https://github.com/my/repo",Name="fork");

Name of the remote, specified as a string scalar or a character vector.

Example: "fork",'origin'

Data Types: char | string

URL used to upload the local repository to the remote repository, specified as a character vector or string scalar.

Data Types: char | string

Output Arguments

collapse all

Details of the remote, returned as a matlab.git.GitRemote object.

Version History

Introduced in R2025a