Remote Git branches that remain after a review or release make shared branch lists harder to scan and can invite new work on a retired branch. Delete the remote branch only after it has been merged, superseded, or intentionally abandoned, because the command removes the shared branch name from the server.
git push <remote> –delete <branch> sends a delete request for the named branch ref on the remote repository. It does not delete a same-named local branch, and other clones may keep stale origin/<branch> remote-tracking names until they fetch or prune.
These steps assume the terminal is inside a clone with push permission to origin and that origin/main is the branch that should already contain the work. Replace those names for repositories that use another remote or default branch; a protected branch or missing permission should produce a server rejection instead of a deletion.
Related: How to merge a Git branch into main
Related: How to delete a local Git branch
Related: How to prune stale remote branches in Git
$ git fetch origin
$ git branch -r --merged origin/main origin/main origin/review/old-login
If origin/review/old-login does not appear here, do not delete it unless the branch is intentionally being retired with unmerged work.
Replace origin/main with the remote branch that should contain the work before cleanup.
This removes the shared branch name from the remote. Confirm the branch name before pressing Enter, especially when the name is close to main, release, or another protected branch.
$ git push origin --delete review/old-login To git@repo.example.net:team/project.git - [deleted] review/old-login
git branch -r -d origin/review/old-login only deletes a local remote-tracking name. Use git push origin –delete when the branch must be removed from the remote repository itself.
$ git fetch --prune origin
Other clones should also fetch with pruning, or run the separate stale-branch cleanup, before their git branch -r output stops showing the deleted branch.
$ git branch -r origin/main
$ git ls-remote --heads origin review/old-login
No output from git ls-remote --heads means the remote no longer advertises that branch name.