If you're working in a repository with a lot of activity, the number of branches created can quickly multiply. Basic GitHub etiquette requires you to delete merged branches or branches that are no longer needed. Here's how.

See also: GitHub: Developer productivity has returned to pre-pandemic levels
You can delete a branch using the GitHub website. However, you can only delete remote branches using this method – you cannot delete local branches from the GitHub website.
To get started, visit the official GitHub website and log in to your account. Once logged in, select the repository containing the Branch you want to delete from the left pane.
Then, click on the “Branch” option under the header menu.
A list of Branches will appear. Locate the one you want to delete, then click the red trash can to the right of it.
The branch has now been deleted. To reflect this change in your local repository, change to the corresponding directory, check out the master branch, and then run the git –pull command from the command line.
See also: GitHub finds 7 code execution vulnerabilities in 'tar' and npm CLI

You can delete both local and remote branches using the command line. First, open the command line of your choice, navigate to the GitHub repository directory (cd
There are two different commands you can run to delete a local branch. If it has already been merged, run:
git branch -d<branch-name>
Or, to delete a branch regardless of its current state, run:
git branch -D<branch-name>
Just replace it.<branch-name> with the real name of your branch.
See also: Copilot: The new AI code generation tool from GitHub and OpenAI
The local branch has now been deleted. If you want to delete a remote branch, you would run:
git push<remote-name> –delete<branch-name>
Replace them<remote-name> and<branch-name> with yours.
The remote branch has now been deleted.
