Main Content


Delete local Git branch

Since R2023b



    deleteBranch(repo,name) deletes the local branch name from the Git™ repository repo.


    collapse all

    After you fix a bug on the BugIssue2 branch and successfully merge your changes into the local branch FeatureA, you want to delete the local BugIssue2 branch.

    Navigate to your repository folder and create a repository object.

    repo = gitrepo;

    Delete the local branch BugIssue2.



    Use tab completion to get the list of available local branches in your repository.

    deleteBranch command in the Command Window with tab completion applied on the branch name argument. Tab completion lists three local branches.

    Input Arguments

    collapse all

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

    Name of the local branch, specified as a string scalar or a character vector.

    Example: "BugIssue1032", 'FeatureB'

    Data Types: char | string

    Version History

    Introduced in R2023b