• 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 

Comments

Yaplex - Freelance developer - white logo on black background

Yaplex is an IT Consulting and .NET development company co-founded by freelance developer Alex Shapovalov who lives in Canada and provides software development services in Canada, USA and all over the world.

Contact Information

Toronto, Canada
Phone: +1 647 328 3809
Email: alex@yaplex.com