Learn Version Control with Git

A step-by-step course for the complete beginner

Deleting Branches

Let's assume our work on "contact-form" is done and we've already integrated it into "master". Since we don't need it anymore, we can delete it:

$ git branch -d contact-form

Tidy as we are, we also delete the remote branch by using the "git push" command with the "--delete" flag:

$ git push origin --delete contact-form

We have now removed both the local and remote versions of the branch.


For our teammates, however, the situation might look a bit different:

  • Fetch with "Prune" Option: Although we deleted the remote branch, it might still show up for other members of our team. To make sure that only active branches are displayed in a remote repository, it makes sense to always use the git fetch command with the --prune option:

$ git fetch origin --prune
  • Local Branches: In case one of our colleagues has created a local branch from the remote version of our contact-form branch, this will of course stay untouched! Deleting a branch on a remote never affects any of the existing local branches.

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.