Branches in a Git Repository

Last modified by Microchip on 2023/11/09 09:12

Creating a Branch

Follow the steps below to create a branch in Git.

In the Projects window, choose a project from the repository in which you want to create the branch.
Menus for creating a branch

In the main menu, choose:
Team > Branch/Tag > Create Branch...

Enter the name of the branch being created.
Create Branch dialog box

Type a specific revision of the selected item or use the Select button.

Review the Commit ID, Author, and Message fields for information specific to the revision being branched from.

Click Create.

Back to top

Checking Out Sources from a Branch

To edit files on a branch that already exists, you can check out the branch to copy the files to your Working Tree.

In the Projects Window, choose a project.

From the Main menu choose:
Team > Checkout > Checkout Revision...

Branch Checkout Dialog box


Specify the required revision or use the Select button
Checkout Selected Revision window

Review the Commit ID, Author, and Message fields information specific to the revision being branched from

To create a new branch out of the checked-out revision, choose the Checkout as New Branch option and enter the Name in the Branch Name field.

Click Checkout

Back to top

Merging Branches

To port modifications from a repository revision to the Working Tree:

In the Projects window, choose a project.

From the main menu choose:
Team > Branch/Tag > Merge Revision
Branch Tag window

Specify the required revision or use the Select button.
Merge revision window

Review the Commit ID, Author, and Message fields for information specific to the revision being branched from.

Click Merge.

Back to top

Deleting a Branch

To delete an unnecessary local branch, complete the following steps:

In the Project window, choose a project.
From the main menu choose:
Team > Repository > Repository Browser
Shows the Team window and repository selection

In the Git Repository Browser, choose the branch to be deleted.

Right-click the selected branch and choose Delete Branch from the popup menu.
Git repository  browser window

In the Delete Branch dialog box, press OK to Confirm the branch deletion.

Back to top