gitrepo - Create Git repository object - MATLAB (original) (raw)

Main Content

Create Git repository object

Since R2023b

Syntax

Description

[repo](#mw%5F536e3e301b05-6c27-4c87-a88b-d859360bfcee%5Fsep%5Fmw%5F986004a2-eb66-491b-9044-75c85face56b) = gitrepo creates amatlab.git.GitRepository object repo for the Git™ repository in the current working folder. You can userepo to manipulate the repository programmatically.

example

[repo](#mw%5F536e3e301b05-6c27-4c87-a88b-d859360bfcee%5Fsep%5Fmw%5F986004a2-eb66-491b-9044-75c85face56b) = gitrepo([folder](#mw%5F536e3e301b05-6c27-4c87-a88b-d859360bfcee%5Fsep%5Fmw%5Fe42db8e7-a6e4-4f00-bc1c-a193dccaab32)) 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)
      Remotes: [1×1 GitRemote]
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]
       Remotes: [1×1 GitRemote] (origin https://github.com/my/repo
 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 amatlab.git.GitRepository object, specified as a character vector or string scalar.

Output Arguments

Version History

Introduced in R2023b