How to Delete a Remote Git Branch

To remove a branch from GitHub or another remote, delete it from the remote repository with git push --delete. This does not delete your local branch. Verify the remote and branch name first, especially when working with branches shared by a team.

Practice Git workflows →

Check the remote and branch name

List your configured remotes and local branches before deleting anything:

git remote -v
git branch --all

In many repositories, origin points to GitHub, but remote names are configurable. Confirm that the branch is no longer needed and that you have selected the intended remote.

Delete the remote branch

Use git push with the --delete option, followed by the remote name and branch name:

git push origin --delete feature/old-navigation

Replace origin with your remote name and use the exact remote branch name. Git may reject the deletion if the branch is protected or you lack permission. Do not bypass project protections or force-delete a branch that teammates still need.

Confirm the branch is deleted

Query the remote directly to check whether it still advertises the branch:

git ls-remote --heads origin feature/old-navigation

If the branch was deleted, this command returns no matching branch line. The command's exit status alone is not a reliable indication of whether a ref was found; inspect its output.

Remove the stale remote-tracking reference

Your local repository may still show an outdated reference such as origin/feature/old-navigation. Prune deleted remote branches with:

git fetch --prune origin

This removes stale remote-tracking references for origin; it does not delete your local branches. To prune all configured remotes, use git fetch --prune.

Remote branch versus local branch

Deleting a remote branch does not remove a branch that exists only on your computer. If you also want to delete a local branch, first switch to a different branch and then use:

git branch -d feature/old-navigation

The -d option protects against deleting a branch Git considers unmerged. For more about local branch removal, see how to delete a Git branch.

Remote branch deletion FAQ

Does deleting a remote branch delete its commits?

It removes the branch name from the remote, not necessarily every copy of its commits. Commits may still be reachable from other branches or references, but do not rely on that as a backup.

Can I delete a branch from GitHub's website?

Yes. GitHub often offers a delete-branch button after a pull request is merged. You can also use the command in this guide for a branch that is no longer needed, subject to repository permissions and branch protection rules.

Learn Git Faster by Practicing

Reading is just the first step. Real learning happens when you practice.

Start Learning Git →