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

# Switch and create branches

> Open the branch picker from the Requestly sidebar to switch branches, create one, resolve uncommitted changes during a switch, and delete a branch you no longer need.

Requestly shows the branch you are on in the sidebar status bar, and puts the whole branch list one click behind it. You can switch, create, and delete branches without a terminal. Git applies to [local projects](/api-client/git/overview#requirements) only, so the **Git** tab is hidden while a team project is active.

<Info>
  Git requires the **desktop app**. [Download Requestly](https://requestly.com/downloads).
</Info>

## Open the branch picker

The status bar at the bottom of the sidebar shows the current branch name, on every tab and not only on the **Git** tab. Click the branch name to open the **Branches** window.

The window holds three parts, top to bottom:

* A **Search branches** box.
* The branch list.
* A **Create branch** row.

<Note>
  The branch name is not clickable while a merge or a rebase is in progress. Finish the merge first, then switch.
</Note>

## Read the branch list

Each row is one branch.

| What you see              | What it means                                                                     |
| ------------------------- | --------------------------------------------------------------------------------- |
| A green check at the left | The branch you are on. The row is not clickable, and it carries no delete action. |
| A **DEFAULT** tag         | The branch is named `main` or `master`. It is a marker, not an action.            |
| A trash icon on hover     | Deletes that branch. See [Delete a branch](#delete-a-branch).                     |

Type in **Search branches** to narrow the list by name. A search that matches nothing reads "No branches match."

<Frame>
  <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-branch-picker.light.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=58196ce35a05079735f6780a7d3fe0c2" alt="The Branches window listing four local branches, with a check beside main, a DEFAULT tag next to it, a search box above, and a Create branch row below" className="dark:hidden" width="1280" height="800" data-path="images/git-branch-picker.light.png" />

  <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-branch-picker.dark.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=e77a4bf7dec5992c36946da246781836" alt="The Branches window listing four local branches, with a check beside main, a DEFAULT tag next to it, a search box above, and a Create branch row below" className="hidden dark:block" width="1280" height="800" data-path="images/git-branch-picker.dark.png" />
</Frame>

<Note>
  The list holds your local branches. A branch that exists only on the remote does not appear, and Requestly does not check one out. Pull instead, to bring the remote's commits into the branch you are on.
</Note>

## Switch to another branch

<Steps>
  <Step title="Open the Branches window">
    Click the branch name in the sidebar status bar.
  </Step>

  <Step title="Pick the branch">
    Click the row you want. With a clean working tree, Requestly switches and closes the window.
  </Step>

  <Step title="Resolve uncommitted changes">
    With staged or unstaged changes in the tree, the **Uncommitted changes** dialog opens first. Choose how to handle them, as described below.
  </Step>
</Steps>

While a switch runs, the window stays open and its controls are disabled. It closes on its own once the switch succeeds.

### When the working tree is not clean

Switching would lose changes you have not committed, so Requestly asks first. The dialog reads "Switching to `<branch>` would lose your current changes. Stash them or discard?" and offers three buttons.

| Button             | What it does                                                                                                                                                                                                  |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Stash & switch** | Stashes your changes, including untracked files, then switches. The stash is recorded as "WIP before switching to `<branch>`" and appears in the [Stashes section](/api-client/git/stashes) of the Git panel. |
| **Discard**        | Throws the uncommitted changes away and switches, in one step.                                                                                                                                                |
| **Cancel**         | Leaves you on the current branch with your changes intact.                                                                                                                                                    |

<Frame>
  <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-checkout-dirty-modal.light.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=01c1cb7f35da4a5d2cd125a4f745244d" alt="The Uncommitted changes dialog asking whether to stash or discard before switching to feature slash pet-search, with Cancel, Discard, and Stash and switch buttons" className="dark:hidden" width="1280" height="800" data-path="images/git-checkout-dirty-modal.light.png" />

  <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-checkout-dirty-modal.dark.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=c8ba959912bbbc9118f8859d9e725ad8" alt="The Uncommitted changes dialog asking whether to stash or discard before switching to feature slash pet-search, with Cancel, Discard, and Stash and switch buttons" className="hidden dark:block" width="1280" height="800" data-path="images/git-checkout-dirty-modal.dark.png" />
</Frame>

<Warning>
  **Discard** cannot be undone. Git keeps no copy of uncommitted work, so use **Stash & switch** whenever you may want the changes back.
</Warning>

## Create a branch

<Steps>
  <Step title="Open the composer">
    Click **Create branch** at the bottom of the **Branches** window.
  </Step>

  <Step title="Name the branch">
    Type the name. Requestly checks it as you type and blocks **Create** until the name is valid.
  </Step>

  <Step title="Decide whether to switch">
    **Check out after creating** is selected by default, so the new branch becomes the current one. Clear it to create the branch and stay where you are.
  </Step>

  <Step title="Create">
    Click **Create**. The new branch starts from the commit you are on, and the window closes.

    <Frame>
      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-branch-create-composer.light.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=222e3a5b2ac020ee5b7254eb9071dd95" alt="The Branches window with the create composer open at the bottom, a new branch name typed in, the Check out after creating box selected, and Cancel and Create buttons" className="dark:hidden" width="1280" height="800" data-path="images/git-branch-create-composer.light.png" />

      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-branch-create-composer.dark.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=095c4aebc369690242da1fa77380fe8a" alt="The Branches window with the create composer open at the bottom, a new branch name typed in, the Check out after creating box selected, and Cancel and Create buttons" className="hidden dark:block" width="1280" height="800" data-path="images/git-branch-create-composer.dark.png" />
    </Frame>
  </Step>
</Steps>

### Names Requestly refuses

| What the field shows                      | Why                                                                                                                                       |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| "Branch names cannot contain spaces."     | The name holds a space.                                                                                                                   |
| "Invalid branch name."                    | The name holds a character Git refuses (`~`, `^`, `:`, `?`, `*`, `[`, `\`), contains `..`, starts or ends with `/`, or ends with `.lock`. |
| "A branch with that name already exists." | The repository already has that branch. The composer stays open so you can rename and retry.                                              |

## Delete a branch

<Steps>
  <Step title="Reveal the delete action">
    Hover the branch you want to remove. The trash icon appears at the right of the row. The branch you are on has none, so switch away from a branch before deleting it.
  </Step>

  <Step title="Confirm">
    The **Delete branch** dialog asks "Delete branch `<name>`? This can't be undone." Click **Delete**.

    <Frame>
      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-branch-delete-confirm.light.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=a5542614a4a3cb1ef37781115d55c430" alt="The Delete branch dialog asking to delete the release slash v1 branch and warning that it cannot be undone, with Cancel and Delete buttons" className="dark:hidden" width="1280" height="800" data-path="images/git-branch-delete-confirm.light.png" />

      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-branch-delete-confirm.dark.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=e141143c3283f019bc86aad42876a807" alt="The Delete branch dialog asking to delete the release slash v1 branch and warning that it cannot be undone, with Cancel and Delete buttons" className="hidden dark:block" width="1280" height="800" data-path="images/git-branch-delete-confirm.dark.png" />
    </Frame>
  </Step>

  <Step title="Force the delete if Git refuses">
    A branch holding commits that are not merged anywhere else cannot be deleted normally. The dialog becomes **Branch not fully merged** and offers **Force delete**, which removes the branch and its unmerged commits with it.
  </Step>
</Steps>

<Warning>
  **Force delete** discards the commits that live only on that branch. Merge or push them first if you want to keep them.
</Warning>

The deleted branch leaves the list straight away, so you can delete several in one visit.

## Next steps

<CardGroup cols={2}>
  <Card title="Browse history and diffs" icon="code-compare" href="/api-client/git/history-and-diffs">
    Read a branch's commits on a graph, and open a read-only diff for a commit or a file.
  </Card>

  <Card title="Stage and commit changes" icon="code-commit" href="/api-client/git/commit-changes">
    Read the change list, stage or discard files, and write a commit.
  </Card>
</CardGroup>
