• Home /
  • Blog /
  • How to delete Git branch both locally and remotely
Git Tutorials

How to delete Git branch both locally and remotely

Delete Git branch locally can be done providing -d parameter to git branch command. In some cases, git can complain than a branch is not fully merged, and it will refuse to delete it, in that case, you can use -D parameter (capital D), it will force Git to remove it.

# remove git branch locally git branch -d branch-name # force git to delete branch locally when it refuse to delete it using previous command git branch -D branch-name

How to delete git branch from a remote repository

In order to remove git branch on a remote git repository, for example, Bitbucket or Github, you need to use the following command

# remove git branch on remote server, the branch is not removed from local machine in this case git push origin --delete branch-name 
Yaplex - Freelance developer - white logo on black background

Yaplex ® is a custom software development company located in Mississauga, Ontario. Yaplex was founded in 2013 and provides website development, mobile development, and custom .NET software development services.

Contact Information

Mississauga, ON, Canada
Phone: +1 647 328 3809
Email: hello@yaplex.com