How to Delete a git Remote Branch

By  on  

Keeping a tidy repository is important; not just a tidy codebase, but a tidy repository in as far as not having spare branches rotting around.  Generally the main repository doesn't keep multiple branches but sometimes you need to push to a main repository simply to get Travis CI to run tests.  Once a branch is merged, for example, we no longer need it around.

Deleting a branch on a local host machine repo is easy:

git branch -d <branch_name>

To remove a branch from the remote git repository, like a GitHub-hosted repository, you can execute:

git push <remote_name> --delete <branch_name>

If you learned something here, check out Delete Merged Branches with git!

Recent Features

  • By
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

  • By
    JavaScript Promise API

    While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready?  Promises are becoming a big part of the JavaScript world...

Incredible Demos

  • By
    Retrieve Your Gmail Emails Using PHP and IMAP

    Grabbing emails from your Gmail account using PHP is probably easier than you think. Armed with PHP and its IMAP extension, you can retrieve emails from your Gmail account in no time! Just for fun, I'll be using the MooTools Fx.Accordion plugin...

  • By
    Create Twitter-Style Dropdowns Using jQuery

    Twitter does some great stuff with JavaScript. What I really appreciate about what they do is that there aren't any epic JS functionalities -- they're all simple touches. One of those simple touches is the "Login" dropdown on their homepage. I've taken...

Discussion

  1. It is even easier to delete a remote branch!

    git push origin :BRANCH_NAME

    Note the colon before the branch.

  2. You can also do

    git push :BRANCH_NAME

    – Note the colon, that states to delete the remote branch!

    • So it seems like it parsed my placeholders as HTML;

      git push origin :develop
      

      Would delete develop branch on the origin remote.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!