Code and repositories / Read code
Find and delete old branches
Your repository has many branches, and you do not know which ones people still use. The Branches page lists every branch, filters it by name, author and age, and deletes a branch from its row.
4 min read
1. Open the Branches page
- Open the repository. The Code tab opens.
- Next to the branch menu, click Branches. The link shows how many branches the repository has.
You can also open /@<owner>/<repo>/branches directly.
The default branch is first, in its own section. The other branches come next, newest tip commit first. A page shows 30 branches. Use Newer and Older at the bottom to move between the pages.
Each row shows:
- The name of the branch. Click it to open its files.
- When the branch was updated, and the title of its tip commit.
- How many commits the branch is behind and ahead of the default branch.
- New pull request, which compares the branch with the default branch.
- Delete, if you have write access.
The row of the default branch shows only the first two.
The behind and ahead counts are exact, with no limit on the length of the history. The forge counts them from the reachability bitmaps of the repository. It writes these bitmaps when it imports a repository and at each full repack. A new repository gets them at its first full repack.
Note
Before the repository has bitmaps, the forge counts by reading the commits, and it stops after 100,000 commits. The same is true when more than 100,000 commits came in after the last full repack. Then the count shows a + after it, because the real count can be higher.
2. Filter the list
Above the list are a search field and two menus:
- Search branches: type a part of the name, then press Enter. Uppercase and lowercase are the same.
- Author: click it, then click a name. This is the author of the tip commit of each branch.
- State: click it, then click Active or Stale. A branch is active when its tip commit is from the last 90 days. An older branch is stale.

You can use the search and the two menus together. For example, click State, then Stale, then pick your own name in Author. The list shows only your old branches.
- A filter change opens the first page of the list again.
- To take a menu filter off, click the X next to the menu.
- If no branch matches, the page says so. Click Clear filters to see every branch again.
3. Share the list
The URL keeps the filters. For example:
/@acme/app/branches?state=stale&author=Ana%20Lee&q=fix
qis the name search.authoris the author name of the tip commit.stateisactiveorstale.pageis the page number.
Send the link to your team. They see the same list.
Note
These filters are on the web only. REST, MCP and src have no command for them.
4. Delete a branch
You need write access to delete a branch.
- Read the ahead count of the branch. If it says
0 ahead, the default branch already has all of its commits. - Click Delete on the row of the branch.
- Click Delete branch to confirm. You cannot undo this.
Tip
If a branch has work that you want to keep, click New pull request on its row, and do not delete it.
Done
- You find the stale branches, or the branches of one author, in one list.
- The link to that list shows your team the same branches.
- You delete each branch that you do not need from its row.