Want to delete a branch in GitLab without causing a small apocalypse on your team
This guide shows the safe ways to delete branches from the GitLab web UI and from the command line with verification steps and a little attitude
Sometimes clicking is faster than typing and less likely to trigger a tragic accidental deletion. Navigate to Project then Repository then Branches. Find the branch you made during a caffeine fueled sprint and click Delete. This is handy for cleaning up branches created by merge requests.
If you prefer the command line or want to script this, push a delete to the remote. Replace origin and feature branch with your actual names
git push origin --delete feature-branch
This tells the remote to drop the branch reference so it no longer shows up for collaborators
Use a lowercase d to refuse deletion if the branch has unmerged changes
git branch -d feature-branch
If you accept potential data loss use a capital D to force removal
git branch -D feature-branch
After the remote is gone tidy your local repo so your branch list does not read like a historical record of bad ideas
git fetch origin
git branch -d feature-branch
Protected branches prevent accidental deletion. If a branch is protected unprotect it in Project Settings then try deletion again or ask a project maintainer to help. Also check the merge request setting to automatically delete the source branch on merge if you want less manual cleanup
Do not trust the web UI more than your own eyes. Run a fetch prune and list remote branches
git fetch --prune
git branch -r
Or check the remote directly
git ls-remote --heads origin
Follow these steps and you will remove branches like a responsible human instead of a reckless chaos agent
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.