Main Content

Connect to GitHub or GitLab from MATLAB

R2026b
Since R2026b

You can manage GitHub® and GitLab® connections directly from the MATLAB® Connections panel. When adding a connection to your GitHub or GitLab account in the Connections panel, you can:

  • Manage GitHub or GitLab authentication.

  • Use one authentication workflow for operations, including clone, fetch, push, and share.

  • Use multiple GitHub and GitLab accounts and link them to specific repositories.

  • Store authentication tokens securely in the MATLAB Vault.

Add Connection to GitHub or GitLab

To add a new connection to GitHub or GitLab, follow these steps.

  1. Open the Connections panel. On the Home tab, in the Environment section, click Connections.

  2. In the Available Connections section, click the Add button next to the connection you want to add.

    The Connection panel showing GitHub connection.

  3. When you choose GitHub or GitLab, enter your personal access token and click Connect.

    Connect to GitHub window asking for your GitHub personal access token.

    If you choose GitHub Enterprise Server or GitLab Self-Managed, specify the server address and your personal access token and click Connect.

    Connect to GitHub window asking for your GitHub personal access token.

View Information and Manage Connections to GitHub or GitLab

In the Connections panel, you can manage connections and view information about the authenticated account.

My connections panel showing how to access the details of an existing GitHub connection.

  • To view your authenticated account information, including the expiration date of the access token and the current GitHub or GitLab API usage and rate limits, in the My Connections section, right-click the connection and select Details.

  • To refresh an expired token of an existing connection to your GitHub or GitLab account, in the My Connections section, right-click the connection and select Refresh Token.

  • To remove the connection to your GitHub or GitLab account, in the My Connections section, right-click the connection and select Remove.

Clone Git Repository After Adding Connection

After you add a GitHub connection in the MATLAB Connections panel, you can quickly clone a remote repository using that account.

  1. On the Home tab, in the Files section, select New > Git Clone.

    The Clone Git Repository dialog box with the Clone from, Account, Repository, and Folder fields, as well as a shallow clone checkbox.

  2. In the Clone Git Repository dialog box, specify:

    • Clone from — Select the source hosting service (for example, GitHub).

    • Account — Select the authenticated account to access the remote repository. MATLAB automatically populates this field with the account you configured in the Connections panel. If you have multiple accounts, you can select a different one.

    • Repository — Enter or select the name of the repository to clone.

    • Folder — Specify the location of the folder where you want to clone the repository. The folder must be empty.

  3. Click Clone.

    By default, MATLAB performs a full clone of the repository. To create a shallow clone from a specific number of commits, select the Only clone the last number commits checkbox. Then, specify the number of commits you want to include in your clone.

See Also

Topics