If you have ever created a branch, pushed it to origin, and then forgotten about it until it became a fossil, welcome to the club. This guide shows how to remove a remote Git branch without drama and how to confirm origin no longer remembers your bad decisions. Commands are the same whether you use GitHub or another Git hosting service.
Before you hit the nuclear button, get an accurate view of what the remote thinks exists. That avoids deleting the wrong branch and starting a support ticket with your future self.
git fetch --prune
This fetch will update remote refs and prune any branches that were deleted on the server. It keeps your local view in sync with origin so you do not chase ghosts.
Only delete your local branch after merging or confirming the work is no longer needed. Use the safe delete first and use force only when you know what you are doing.
git branch -d feature/name
If Git refuses because the branch is unmerged and you are sure you want to destroy it, use this:
git branch -D feature/name
Remember that -d will protect you from losing commits. -D will not. Choose wisely unless you enjoy rewriting history as a hobby.
Deleting a remote branch is mostly a single push command wrapped in a little ceremony. This tells origin to drop the named branch.
git push origin --delete feature/name
That is the modern explicit form. Older tutorials may show pushing an empty ref but do not follow those into the internet dark ages.
Always confirm origin no longer lists the branch. A quick check prevents surprise reappearances during sprint demos.
git branch -r
git ls-remote --heads origin
If neither command shows the branch name then congrats. The branch is gone from origin and you can go drink something celebratory or pretend you meant to do this all along.
Deleting a remote branch is simple when you follow these steps. Fetch first, delete local only when safe, push the delete, and then verify. Your repository will thank you or at least stop cluttering the branch list.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.