Main Content

gitrepo

Create Git repository object

Since R2023b

    Description

    repo = gitrepo creates a matlab.git.GitRepository object repo for the Git™ repository in the current working folder. You can use repo to manipulate the repository programmatically.

    example

    repo = gitrepo(folder) creates a matlab.git.GitRepository object repo for the Git repository in the specified folder.

    example

    Examples

    collapse all

    Open the Times Table App project repository and create a repository object.

    openExample("matlab/TimesTableProjectExample")
    repo = gitrepo
    repo = 
    
      GitRepository with properties:
    
        WorkingFolder: "C:\myWorkSpace\examples\TimesTableProjectExample"
            GitFolder: "C:\myWorkSpace\examples\TimesTableProjectExample\.git"
        CurrentBranch: [1×1 GitBranch]  (main)
           LastCommit: [1×1 GitCommit]  (566d916)
        ModifiedFiles: [0×1 string]
       UntrackedFiles: [1×1 string]
               IsBare: 0
            IsShallow: 0
           IsDetached: 0
           IsWorktree: 0 

    Create a repository object for a specified folder.

    repo = gitrepo("newrepo\")
    repo = 
    
      GitRepository with properties:
    
         WorkingFolder: "C:\workSpace\newrepo"
             GitFolder: "C:\workSpace\newrepo\.git"
         CurrentBranch: [0×0 GitBranch]
            LastCommit: [0×0 GitCommit]
         ModifiedFiles: [0×1 string]
        UntrackedFiles: [2×1 string]
                IsBare: 0
             IsShallow: 0
            IsDetached: 0
            IsWorktree: 0

    Input Arguments

    collapse all

    Path of the repository folder for which the function creates a matlab.git.GitRepository object, specified as a character vector or string scalar.

    Output Arguments

    collapse all

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

    Version History

    Introduced in R2023b