Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

gitrepo

创建 Git 存储库对象

自 R2023b 起

    说明

    repo = gitrepo 为当前工作文件夹中的 Git™ 存储库创建一个 matlab.git.GitRepository 对象 repo。您可以使用 repo 以编程方式操作该存储库。

    示例

    repo = gitrepo(folder) 为在指定的 folder 中的 Git 存储库创建一个 matlab.git.GitRepository 对象 repo

    示例

    示例

    全部折叠

    打开 Times Table App 工程存储库,并创建一个存储库对象。

    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 

    为指定的文件夹创建一个存储库对象。

    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

    输入参数

    全部折叠

    函数在其中创建存储库的文件夹的路径,指定为字符向量或字符串标量。

    输出参量

    全部折叠

    Git 存储库,以 matlab.git.GitRepository 对象形式返回。

    版本历史记录

    在 R2023b 中推出