Branch Manager - View Git repository history and manage local and remote Git branches and repositories - MATLAB (original) (raw)

View Git repository history and manage local and remote Git branches and repositories

Since R2025a

Description

The Branch Manager is an interactive tool for visualizing and managing local and remote Git™ branches, worktrees, and repositories.

Use the Branch Manager to:

Branch Manager tool. Toolstrip on the top, commits graph in the center, branches, remotes, and tags on the left, and details about selected commits on the right.

Open the Branch Manager

Open the Branch Manager from one of these locations:

Examples

expand all

When you open the Branch Manager for a Git repository, by default, the tool shows the entire Git commit graph in the center; the list of branches, remotes, and tags on the left; and the details about selected commits on the right. In the graph, to understand the current state of different lines of development and important checkpoints in your project history, branches and tags are visually represented using different colors and labels.

Branch Manager shows the toolstrip on the top; the commit graph in the center; branches, remotes, and tags on the left; and details about selected commits on the right.

To inspect a commit, click on the commit in the graph to see its detailed information. The Commit Details pane on the right shows information including the commit message, the username, email, and avatar of the author, the commit date and ID, and any associated changes and commit differences.

In the Branch Manager, you can filter the graph by branch and to search the commit history for specific terms. Filtering the graph helps you isolate relevant pieces of history in large repositories.

You can find a commit by searching for a term in the commit message, for the author name or email, for the date of the commit, or for the commit ID. In the Branch Manager toolstrip, click Find, and enter your search term in theFind tool. The Branch Manager only keeps the commits that match your search and highlights the matching text in yellow.

Find capability in Branch Manager. The text "build" in the Find tool above the history graph. The graph only shows commits that have the text "build" highlighted in yellow.

To filter the commit history to a specific branch, in the left pane, right-click the branch name and select Filter History. The Branch Manager restricts the history to the selected branch. To clear the filter, click the History filtered by branchname filter.

Filter by branch capability in Branch Manager. The graph only shows commits on the selected branch.

You can tag a commit to mark a new version or a stable release. Tags provide an easy way to navigate to an important commit in the code history. Commonly, Continuous integration and continuous delivery (CI/CD) pipelines rely on tags to trigger specific actions, such as building and deploying a new version of your application.

To create a tag, in the Branch Manager toolstrip, click New Tag. In the New Tag dialog box, specify the tag name and clickCreate. By default, Branch Manager creates a tag from theHEAD commit. You can also create a tag from a selected commit, branch, or tag.

New Tag dialog box shows the Tag name field on top, Created from options in the middle, and Create and Cancel buttons at the bottom.

The left pane of the Branch Manager lists all tags from the most recent to the oldest in the Tags section.

To navigate to a tagged commit in the history graph, in the left pane of the Branch Manager, in the Tags section, click a tag. The Branch Manager selects the corresponding commit and navigates to it.

To delete a tag, in the left pane of the Branch Manager, right-click a tag in theTags section and select Delete Tag.

Left pane of the Branch Manager shows the Context menu on a tag in the Tags section and the pointer on the Delete Tag option.

To push a tag to a remote, in the left pane of the Branch Manager, in theTags section, right-click the tag you want to push and selectPush Tag. Then, in the Push Tag dialog box, specify the remote you want to push the tag to and click Push.

To fetch tags, in the left pane of the Branch Manager, in theRemotes section, right-click the remote you want to fetch from and select Fetch Tags.

To fetch all tags from all remotes including newly added tags to commits you already have, in the left pane of the Branch Manager, under the Remotes actions button in theRemotes section, select Fetch All Tags.

Left pane of the Branch Manager shows the Remotes context menu options.

You can also create a branch from a tag. For more information, see Create, Manage, and Merge Git Branches.

You can compare file changes between two tags. For more information, see Compare Files Between Commits or Branches.

In the Branch Manager, you can compare file changes between two revisions, including revisions on different branches.

To examine the differences between two revisions, in the commit graph, hold theCtrl key and select the two different revisions.

The pane on the right lists the files that changed between the two branches, including added and deleted files, under Differences between_id1_ and id2.

Tip

If you select only one commit, by default, the right pane lists the files that change between the selected commit and its parent commit.

Branch Manager shows two commits selected in the graph. A list of modified files on the right shows the context menu for a file with the pointer on the Show Differences option.

To understand changes in a file, run a comparison analysis. Right-click the file and select Show Differences.

You can save a copy of the file you select for either revision. Right-click a file and select Save As to save a copy of the file revision you select. Select Save Parent As to save a copy of the file for the prior revision. Save copies of files if you want to test how the code ran in previous revisions or on other branches.

When you create a local Git repository in MATLAB®, you must add a remote before you push changes. For an example on how to initialize a local Git repository, see Create Local Git Repository in MATLAB.

To add a remote URL to your local repository, in the toolstrip of the Branch Manager, click Add Remote.

Alternatively, in the left pane of the Branch Manager, under the Remotes actions button in the Remotes section, select Add Remote.

Left pane of the Branch Manager shows the Remotes context menu options.

After you create a remote on the platform that will host your repository, such as on GitLab® or BitBucket, specify the name and the URL of the remote you created in the Add Remote dialog box. Then, click Add.

Add Remote dialog box shows Name and URL fields and Add and Cancel buttons at the bottom.

Push your changes to the remote repository. In the Branch Manager, clickPush.

Git worktrees allow you to work on multiple branches of the same repository simultaneously without needing to clone the repository multiple times.

Create a worktree for the main branch in your repository.

Make sure you switch to a different branch that the main branch. Then, in the Branch Manager toolstrip, click New Worktree.

Alternatively, in the left pane of the Branch Manager, in theBranches section, right-click the branch you want to associate with the worktree and select New Worktree.

Left pane of the Branch Manager shows a context menu on a branch in the Branches section with the pointer on the New Worktree option.

In the New Worktree dialog box, in the Worktree folder field, specify the folder you want to use for the new worktree. If you do not want to change the current folder to the worktree folder, clear the Change current folder to worktree folder check box before you clickCreate.

New Worktree dialog box

The Branch Manager creates the worktree and opens the correspondingworktreefolder.git document.

Two Branch Manager worktree windows

You can identify a worktree by a Worktree label.

The Branch Manager labels the working folder that contains the.git folder with a Main Worktree label. It is not possible to delete the main worktree.

If you clear the Change current folder to worktree folder check box when you create the worktree, you must switch to the worktree before making changes. In the left pane of the Branch Manager, right-click the worktree and selectSwitch to this Worktree.

To delete a worktree, right-click the worktree and select Delete Worktree.

Note

Before you delete a worktree, make sure you commit all changes in the worktree to the branch associated with the worktree.

Using the Branch Manager, you can manage remote branches and repositories from a local Git repository.

If you have not set a remote repository for your local repository, see Add Git Remote.

You can perform these tasks in Branch Manager to manage a remote repository.

You can perform these tasks in Branch Manager to manage a remote branch.

By default, MATLAB performs a full clone of a Git repository. To create a shallow clone instead, specify the number of commits to clone in the Clone Git Repository dialog box. For more information, see Create Local Git Repository in MATLAB.

Clone Git Repository dialog box shows a URL and Folder location, one check box for shallow clone, and Clone and Cancel buttons.

To convert a shallow clone to a full clone, in the toolstrip of the Branch Manager, click Unshallow Repository.

The Branch Manager clones the remaining commits and updates the commit history graph to show the complete history.

Git cherry-picking is the process of picking a commit from a branch and applying it to another branch. Cherry-picking can be useful for restoring a revision and undoing changes. For example, if a user commits a change to the wrong branch, you can switch to the correct branch and cherry-pick the commit to it.

To cherry-pick a commit from the featureBranch to themainbranch , follow these steps.

  1. In the Branch Manager toolstrip, switch to the main branch.
  2. In the commit graph, right-click the commit you want to cherry-pick and selectCherry-pick into main.
  3. In the Cherry-Pick dialog box, keep the default option selected. Then, clickCherry-Pick.
    To cherry-pick a tag instead, select the Tag option and choose from the available tags. Then, clickCherry-Pick.

If a conflict occurs during the cherry-picking process, you see a dialog box to resolve the conflict. For information on how to resolve conflicts, see Resolve Git Conflicts.

You can also discard the cherry-picking process and restore to the state of your repository before the cherry-pick. In the Branch Manager toolstrip, clickDiscard Cherry-Pick.

After you complete the cherry-picking process, the commit graph shows the cherry-picked commit in the main branch.

Version History

Introduced in R2025a