Nono.MA

Delete a local Git branch

SEPTEMBER 1, 2022

Here's how to remove a local Git branch.

# Delete a local branch
# -d is a shorthand for --delete
git branch -d your-branch-name
# Deleted branch your-branch-name (was f9b622c).

# Force delete a local branch (regardless of the branch merge status)
# -D is a shorthand for --delete --force
git branch -D your-branch-name
# Deleted branch your-branch-name (was f9b622c).

Remember that you will also have to delete the Git branch from your remote repository as a separate step.

Here's how to remove a remote Git branch without using an app or a website user interface, say, GitHub or GitLab.

# Delete a remote Git Branch (assuming your remote is called origin)
git push origin --delete your-branch-name
# To bitbucket.org:nonoesp/some-repo.git
#  - [deleted]         your-branch-name

BlogCodeGit