Git: Delete a Remote Branch
Last updated
Deleting a branch locally doesn't remove it from the remote - that's a separate step. To delete a branch on the remote (like GitHub), run git push origin --delete <branch>. Afterwards, other clones may still show the branch until they prune stale remote-tracking references.
Try these in the terminal playground - a real shell in your browser, nothing to install.
Syntax
| Command | What it does |
|---|---|
git push origin --delete feature | Delete feature on the remote |
git push origin :feature | Older colon syntax, same effect |
git branch -d feature | Delete the branch locally too |
git fetch --prune | Remove stale remote-tracking branches |
Full cleanup
Remove the branch everywhere and tidy stale refs.
| Step | Command | Result |
|---|---|---|
| 1 | git push origin --delete feature | Gone from the remote |
| 2 | git branch -d feature | Gone locally |
| 3 | git fetch --prune | Clears origin/feature tracking ref |
Git delete remote branch FAQ
How do I delete a remote branch in Git?
Run
git push origin --delete <branch>. This removes the branch from the remote (for example GitHub). The older equivalent is git push origin :<branch>. Deleting the remote branch does not delete your local copy - do that separately with git branch -d <branch>.Does deleting a local branch delete the remote one?
No.
git branch -d only removes the branch from your local repository. The branch stays on the remote until you explicitly delete it with git push origin --delete <branch>. The two are independent.Why does the deleted branch still show up?
Other clones keep remote-tracking references (like
origin/feature) until they prune them. Run git fetch --prune (or git remote prune origin) to remove references to branches that no longer exist on the remote.What's the difference between --delete and the colon syntax?
They do the same thing.
git push origin --delete <branch> is the clearer modern form; git push origin :<branch> is the older syntax (pushing "nothing" to the remote branch, which deletes it). Use --delete for readability.Can I practice this online?
Yes. Open the terminal playground to run these commands in a real shell in your browser - nothing to install. Coddy's free interactive Git course also covers working with remotes step by step.