branch

/brɑːntʃ/noun

A branch is a separate line of development in version control. Developers can make and test changes on it without immediately changing the main version of the code.

The developer created a new branch for the change to the login screen.

A branch is a line of development within a repository. In systems such as Git, a new branch starts at an existing Glossary · In briefcommitA commit is a recorded version of files in a version control system. Each commit marks a point in a project's development history.Read more. The branch then advances as a developer adds new commits. Several changes can be developed alongside one another while the main branch remains available for completed work.

What is a branch used for?

A team can create a separate branch for a new feature, bug fix or experiment. Changes on that branch do not yet affect other lines of development. A developer can save intermediate commits, share code and run automated tests without immediately adding unfinished work to the main branch.

A developer can submit the change for review through a merge request or Glossary · In briefpull requestA pull request proposes that changes from one branch be reviewed and merged into another. Team members can discuss and check the code before it is incorporated.Read more. Colleagues examine the code and provide feedback. Once the change is ready, the team merges the branch into its target branch.

A branch is not a copy of the project

A branch is often described as a separate copy of the code, but Git does not copy every file to create one. The branch name points to the latest commit in that line of development. As work continues, it moves to the newest commit added to it.

Branches can exist locally or be shared with the team through a central repository. After merging, a temporary branch can be deleted; commits included in the main branch remain part of the version history.