Main Content

log

Display record of commits in Git repository

Since R2023b

    Description

    commitHistory = log(repo) returns the record of commits in the Git™ repository repo.

    example

    commitHistory = log(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;

    Display the commit history for the entire repository.

    commitHistory = log(repo);
    

    Navigate to your repository folder and create a repository object.

    repo = gitrepo;

    Display the commit history for a specific file on the current branch in your repository.

    commitHistory = log(repo.CurrentBranch,File="utilities\cleanup.m");
    

    Display the commit history up to and including the revision 0fb701b.

    commitHistory = log(repo.CurrentBranch,File="utilities\cleanup.m",Revisions="0fb701b");

    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: log(repo.CurrentBranch,Revisions="08a4c49")

    File to query, specified as a string scalar or character vector. If you do not specify this input, the function returns the commit history for all files.

    This input supports files that exist only in the repository history, even if they no longer exist on the local disk.

    Example: "newfile.m"

    Data Types: char | string

    Revision specifiers (ID), specified as a string scalar, a string vector, or a character vector. If you do not specify this input, the function prints the commit history from the first to the most recent commit.

    Commit IDs support short, full, and relative commits.

    Example: "08a4c49", "08a4c49d249a4dc3d998b473cdda186f1c05dfd0", "08a4c49^1"

    Data Types: char | string

    Output Arguments

    collapse all

    Commit history, returned as a table.

    Version History

    Introduced in R2023b