If you like typing commands and feeling slightly powerful then the command line is your friend. Start by syncing your local view of the server so you are not chasing ghosts.
git fetch origin --prune
git branch -r
Pruning removes stale remote references that no longer exist on the server. Now remove the branch from the remote with the blunt but effective command below.
git push origin --delete BRANCH_NAME
There is an older alternative that still works if you enjoy confusing new hires.
git push origin BRANCH_NAME
The first form reads better at stand ups and makes it look like there is a plan.
Only use force when you know what you are doing. For remote branches the push delete command is usually enough. For local branches use the force flag if the branch is not merged and you want to obliterate it without mercy.
If you prefer buttons and the soothing illusion of safety then the GitLab web UI is your jam. Open your project, go to Repository then Branches and click the delete button next to the branch name. This is handy when reviewers or pipeline rules demand a human in the loop.
After deletion confirm the branch is gone on the server and prune local references so old names do not haunt future work.
git ls-remote --heads origin BRANCH_NAME
git fetch origin --prune
Then remove any stray local branch. Use the safe delete when merged and force delete if you must.
git branch -d BRANCH_NAME
git branch -D BRANCH_NAME
Protect important branches using GitLab branch protection rules so no one can accidentally delete main or production. Use clear naming like feature or bugfix and add expiration labels if your repo breeds short lived branches
Use merge requests and CI checks to avoid deleting branches that still matter. Good naming and a bit of housekeeping will save you from mysterious deploy failures at 3 am.
Deleting remote branches in GitLab is simple and either the CLI or the web UI works. Fetch and prune first, delete on the server, verify, then prune and remove local branches to keep your repo tidy. Do this and you will reduce clutter and avoid the ghost branch horror stories that keep devops engineers awake at night.
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.