Main Content

fetch

Download new data from remote Git repository

Since R2023b

    Description

    fetch(repo) downloads new data from all registered remotes for the local Git™ repository repo.

    example

    fetch(repo,Name=Value) specifies additional options as one or more name-value arguments.

    example

    Examples

    collapse all

    Navigate to your repository folder and create a repository object.

    repo = gitrepo;

    Download new data from all registered remotes.

    fetch(repo);
    

    To fetch from a passphrase-protected remote repository, specify your login information for the Git repository account, for example GitHub®. For more information, see Download Data from Specified Remote.

    Navigate to your repository folder and create a repository object.

    repo = gitrepo;

    Download new data from the origin remote on a passphrase-protected repository.

    secrets = loadenv("github.env");
    fetch(repo,Username=secrets("GITHUB_USER"),Token=secrets("GITHUB_TOKEN"),Remote="origin");
    

    To prevent frequent login prompts when you interact with your remote repository using HTTPS, configure a Git credential manager to remember credentials. For more information, see Manage Git Credentials.

    Input Arguments

    collapse all

    Git repository, specified as a matlab.git.GitRepository object.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=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: fetch(repo,Username="myusername",Token="mypersonaltoken",Remote="origin")

    Username for the Git repository account, specified as a character vector or string scalar.

    Data Types: char | string

    Personal access token for the Git repository account, specified as a character vector or string scalar.

    Data Types: char | string

    Name of the remote from which the function downloads data, specified as a character vector or string scalar.

    Data Types: char | string

    Version History

    Introduced in R2023b