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

# Branches

> Creating, renaming, tracking, deleting, and cleaning up branches

Branch actions live in the commit graph's **right-click** menu, and on the **Local Branches** rows of the **Repository** panel.

## Creating a branch

Right-click the commit to use as the base and choose **Create branch…**.
Enter a **Branch name** and click **Create**.
The **Checkout after creating** toggle is on by default.

<Frame>
  <img src="https://mintcdn.com/railgit/SdJRWXTrBLj1X7EN/images/history-branch-create.png?fit=max&auto=format&n=SdJRWXTrBLj1X7EN&q=85&s=109ab4e37c502a4d1bc683c085d056fa" alt="The dialog for creating a new branch from a base commit, with the name input field and the Checkout after creating toggle" width="886" height="480" data-path="images/history-branch-create.png" />
</Frame>

## Renaming a branch

Right-click a commit with a branch badge and choose **Rename…** from that branch's submenu.
The input field is pre-filled with the current name, and if the branch is pushed to a remote, an **Also rename on origin** toggle appears (off by default).
The label names the remotes the branch is on. With two of them it reads **Also rename on origin, upstream**.

<Note>
  * You can rename the branch you currently have checked out.
  * Renaming on the remote follows the sequence "push the new name → delete the old name on success".
  * Remote-only branches can't be renamed.
</Note>

## Setting a tracking branch

Choose **Set tracking branch…** to pick which remote branch a local branch tracks.
It's in the branch submenu in the graph and on the **Local Branches** rows of the **Repository** panel, and it works on the branch you currently have checked out too.

* **Branch** is the branch being changed, shown read-only.
* **Tracking branch** is a searchable list of every remote branch in the repository. Pick **No tracking branch** to clear the setting.

The tracking branch is what the [ahead/behind counts](/remote/push-pull-fetch#the-aheadbehind-count-badges) compare against, and it's the first thing Pull and Fetch consult when choosing a remote.

<Note>
  Only the git config changes. No commits move and no working tree files change.
  It isn't recorded in Undo, and you reverse it by reopening the same dialog.
</Note>

<Tip>
  With more than one remote, `origin/main` and `upstream/main` are separate branches that share a name, and this dialog is the only way to point a branch at the right one.
  Pushing with `-u` creates a tracking relationship where there is none; it doesn't correct one that's already wrong.
</Tip>

## Creating a pull request

Choose **Create pull request…** from the branch submenu to open a GitHub pull request with that branch as the head.
The entry appears only for repositories with a github.com remote.
[Pull requests](/remote/pull-request) covers the dialog.

## Deleting a branch

Choose **Delete** from the branch submenu.
The **Also delete on origin** toggle in the confirmation modal also deletes the branch on the remotes its label names.

<Warning>
  You can't delete the branch you currently have checked out.

  Git refuses to delete a branch that has unmerged commits.
  Clicking **Force delete** in the error notification deletes it immediately with no further confirmation, and commits that exist on no other branch may be lost.
</Warning>

## Cleaning up branches

Delete local branches already merged into a base branch, all at once.
Open it from **Clean up merged branches** in the **Cleanup** menu on the top bar (it only appears in the main worktree).

<Steps>
  <Step title="Check the base branch">
    **Compare against** defaults to the repository's default branch, falling back to the branch you have checked out, and you can switch it to another local branch from the dropdown.
    If HEAD is detached and no default can be resolved, **Pick a base branch to compare against.** appears instead.
  </Step>

  <Step title="Pick the targets">
    Candidates are listed by name with a short SHA and a **Merged** badge, all selected to begin with.
    Clear them one at a time with the checkboxes, or flip them all with **Select all**.
  </Step>

  <Step title="Delete">
    Click **Delete {count}** and the selected branches are deleted one after another.
    A failure on one doesn't stop the rest; a toast reports how many were deleted and which ones failed.
  </Step>
</Steps>

A branch is left out of the candidates when it is:

* the base branch itself, or the branch you have checked out
* checked out in another worktree: Git refuses to delete those
* not merged into the base branch: a branch counts as merged only when its tip is the base branch's tip or an ancestor of it

<Note>
  The merge check runs entirely on the local commit graph. It works in repositories without a remote.
  It also deletes local branches only. Remote branches are left alone.
  You can reverse a cleanup in one step with [Undo](/basics/discard-undo).
</Note>

<Warning>
  The candidate list is only fetched when the dialog opens and when you change the base branch.
  If a target branch (or the base branch) has moved since then, that branch is skipped, and a toast explains why.
  Reopen the dialog to re-check it.
</Warning>
