Git: Working with Branches

See Also

The IDE enables you to maintain different versions of an entire code base using branches, which involves:

Creating a Branch

Creating a branch enables you to work on a separate version of your file system for stabilization or experimentation purposes without disturbing the main trunk.

To create a local branch:

  1. In the Projects or Files window, choose a project or folder from the repository in which you want to create the branch.
  2. Choose Team > Git > Branch > Create Branch from the main menu (alternatively, right-click the versioned project or folder and choose Git > Branch > Create Branch in the popup menu). The Create Branch dialog box displays.
  3. In the Branch Name field, enter the name of the branch being created.
  4. Type a specific revision of the selected item by entering a commit ID, existing branch, or tag name in the Revision field or press Select to view the list of revisions maintained in the repository and choose a required one.
  5. Review the Commit ID, Author, Message fields information specific to the revision being branched from and click Create.
    The branch is added to the Branches/Local folder of the Git repository.

Checking Out

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

To check out a revision:

  1. Choose Team > Git > Checkout > Checkout Revision from the main menu. The Checkout Selected Revision dialog box displays.
  2. Specify the revision required by entering a commit ID, existing branch, or tag name in the Revision field or press Select to view the list of revisions maintained in the repository and specify a required one.

    Note:

  3. Review the Commit ID, Author, Message fields information specific to the revision being checked out.
  4. 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.
  5. Press Checkout to check out revision.
    Files in the Working Tree and in the Index are updated to match the version in the specified revision.

Merging

Merging enables you to port modifications from a repository revision to the Working Tree.

To merge:

  1. Choose Team > Git > Merge Revision from the main menu.
    The Merge Revision dialog box displays.
  2. Specify the revision required by entering a commit ID, existing branch, or tag name in the Revision field or press Select to view the list of revisions maintained in the repository and specify a required one.
  3. Review the Commit ID, Author, Message fields information specific to the revision being merged.
  4. Press Merge.
    A three-way merge between the current branch, your Working Tree contents, and the specified branch is done.

    Note:

Deleting

You can delete an unnecessary local branch.

To delete a branch:

  1. Choose Team > Git > Repository Browser from the main menu.
  2. In the Git Repository Browser, choose the branch to be deleted.

    Note:

  3. Right-click the selected branch and choose Delete Branch from the popup menu.
  4. In the Delete Branch dialog box, press OK to confirm the branch deletion.
    The branch is removed from the local repository as well as the Git Repository Browser.
See Also
About Git Support
Git Tasks: Quick Reference
Git: Working with Remote Repositories

Legal Notices