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:
- In the Projects or Files window, choose a project or folder from the repository in which you want to create the branch.
- 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.
- In the Branch Name field, enter the name of the branch being created.
- 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.
- 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:
- Choose Team > Git > Checkout > Checkout Revision from the main menu. The Checkout Selected Revision dialog box displays.
- 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:
- If the specified revision refers to a valid commit that is not marked with a branch name, your HEAD becomes detached and you are no longer on any branch.
- Review the Commit ID, Author, Message fields information specific to the revision being checked out.
- 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.
- 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:
- Choose Team > Git > Merge Revision from the main menu.
The Merge Revision dialog box displays.
- 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.
- Review the Commit ID, Author, Message fields information specific to the revision being merged.
- Press Merge.
A three-way merge between the current branch, your Working Tree contents, and the specified branch is done.
Note:
- After merging you must still commit the changes in order for them to be added to the HEAD.
Deleting
You can delete an unnecessary local branch.
To delete a branch:
- Choose Team > Git > Repository Browser from the main menu.
- In the Git Repository Browser, choose the branch to be deleted.
Note:
- The branch must be inactive, i.e. not currently checked out into the Working Tree.
- Right-click the selected branch and choose Delete Branch from the popup menu.
- 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