A branch is an independent line of development in a Git repository. Each branch points to a specific commit and lets you work on changes without affecting other branches. The main branch (main or master) contains stable code, while secondary branches contain work in progress.

How it works

When you create a branch, Git creates a pointer to the current commit. From that point on, commits made on the new branch do not appear on the original branch. This lets you develop features, fix bugs or experiment without risk of breaking the main code.

When the work is ready, you merge the branch back into main. Git combines the changes, resolving conflicts when the same lines were modified in both branches. Branches can be local or remote, and it is common to use one branch per feature or per task.

Practical example

A developer creates the branch feature/login to implement authentication. While working on that branch, another developer fixes a bug on the branch fix/typo. The two pieces of work do not interfere. When both are done, they merge into main and the final code contains both changes.

In the context of coding agents, each agent can work on its own branch, avoiding conflicts. When an agent finishes, its work is reviewed and merged, keeping the history organized.

What it's used for

Branches are the foundation of collaborative development and the workflow with AI agents. In bridgecode, each agent in a squad can operate on an isolated branch, allowing controlled review and merge of each contribution.