How to Delete a Remote Branch in Git
Delete a branch from remote origin (GitHub, GitLab, Bitbucket) after a pull request has been merged.
git push origin --delete <branch-name>Step-by-Step Execution Guide
git push origin --delete feature-branchSends a delete command to remote origin for the specified branch.
git branch -d feature-branchSafely deletes the local branch if it has already been merged.
git branch -D feature-branchForces deletion of local branch even if not fully merged into current branch.
git fetch --pruneRemoves local references to remote branches that were deleted by other team members.
Critical Pitfalls & Precautions
- β’Cannot delete the remote branch if it is set as the repository's Default Branch on GitHub/GitLab.
Delete Remote Branch - Frequently Asked Questions
Common questions about safe rollback, remote history implications, and troubleshooting.
Git keeps cached references locally. Run "git remote prune origin" or "git fetch --prune" to synchronize and clean them.
Related Git Command Guides
Browse All Git RecipesUndo your most recent Git commit while keeping all your edited files staged or unstaged in your working directory.
Discard all unstaged and uncommitted file modifications and restore your working tree to the latest commit.
Rename your current local branch and update the upstream remote tracking branch on GitHub or GitLab.
Amend the commit message of your latest commit before or after pushing.
Remove files from the Git staging area (index) without losing any of your local changes.
Temporarily shelve both modified and newly created untracked files to switch branches with a clean working copy.