GitLab delete branch example |Video upload date:  · Duration: PT5M39S  · Language: EN

Delete branches in GitLab from web UI local and remote with safe steps verification and tips

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

Delete a branch from the GitLab web interface

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.

  1. Open the Branches page in the project
  2. Locate the branch name
  3. Click Delete and confirm

Remove the remote branch with git

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

When to force delete

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

Clean up the local copy

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

Check protected branches and merge requests

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

Verify the branch is actually gone

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

Quick recap and naming tips

  • Web UI for quick one off cleanup
  • git push origin --delete to remove remote references
  • git branch -d or -D to manage local copies
  • Check protected branches before you try to delete anything
  • Use clear prefixes like feature slash bugfix slash hotfix to keep branches sane

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.