> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vibehub.co.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Branches

> Create and manage branches in your VibeHub projects

## Overview

Branches let you work on different features or experiments without affecting your main codebase. VibeHub provides Git-like branching with an intuitive visual interface.

## Why Use Branches?

* **Isolate work** - Develop features without affecting stable code
* **Collaborate safely** - Multiple people can work on different branches
* **Experiment freely** - Try ideas without risk to your main branch
* **Review before merging** - Compare and approve changes before they go live

## The Branch Selector

The branch selector dropdown appears in your project header. It shows:

* Current branch name
* List of all branches
* Option to create new branches

## Branch Indicators

| Icon   | Meaning                         |
| ------ | ------------------------------- |
| Star   | Default branch (usually `main`) |
| Shield | Protected branch                |
| Check  | Currently selected branch       |

## Creating a Branch

<Steps>
  <Step title="Open Branch Selector">
    Click on the branch dropdown in your project header
  </Step>

  <Step title="Enter Branch Name">
    Type a name for your new branch in the input field at the bottom
  </Step>

  <Step title="Create">
    Click **Create Branch** or press Enter
  </Step>
</Steps>

Your new branch is created from the current branch's latest commit (HEAD).

### Branch Naming Tips

<Tip>
  Use descriptive, lowercase names with hyphens. Include prefixes to categorize:

  * `feature/user-auth`
  * `fix/login-bug`
  * `experiment/new-ui`
</Tip>

## Switching Branches

Click on any branch name in the dropdown to switch to it. When you switch:

* The file browser updates to show that branch's files
* The commit history shows that branch's commits
* Any new commits you push will go to this branch

## The Default Branch

Every project has a default branch (typically `main`). This is:

* The branch shown when someone first opens your project
* Usually represents production-ready code
* Cannot be deleted
* Often protected from direct pushes

### Changing the Default Branch

1. Go to project **Settings**
2. Find branch management section
3. Select a new default branch

<Warning>
  Changing the default branch affects how others see your project. Make sure the new default contains stable code.
</Warning>

## Protected Branches

Protected branches have extra safeguards:

* Cannot be deleted
* May require reviews before merging
* Indicated with a shield icon

## Deleting a Branch

<Steps>
  <Step title="Open Branch Selector">
    Click on the branch dropdown
  </Step>

  <Step title="Find the Branch">
    Locate the branch you want to delete
  </Step>

  <Step title="Delete">
    Click the trash icon next to the branch name
  </Step>

  <Step title="Confirm">
    Confirm the deletion when prompted
  </Step>
</Steps>

<Warning>
  Deleting a branch removes all commits that exist only on that branch. This cannot be undone.
</Warning>

### Branches You Can't Delete

* The default branch
* Protected branches
* The currently selected branch (switch first)

## Branch Workflow Example

Here's a typical workflow using branches:

```mermaid theme={null}
gitGraph
   commit id: "Initial commit"
   branch feature/login
   commit id: "Add login form"
   commit id: "Add validation"
   checkout main
   commit id: "Update readme"
   checkout feature/login
   commit id: "Add tests"
   checkout main
   merge feature/login id: "Merge login feature"
```

1. Start on `main` with stable code
2. Create `feature/login` branch
3. Make commits on the feature branch
4. Meanwhile, `main` might get other updates
5. When ready, merge `feature/login` into `main`
6. Delete the feature branch (optional)

## Next Steps

<CardGroup cols={2}>
  <Card title="Compare Branches" icon="code-compare" href="/version-control/comparing-branches">
    See what's different between branches
  </Card>

  <Card title="Merge Branches" icon="code-merge" href="/version-control/merging">
    Combine changes from different branches
  </Card>
</CardGroup>
