Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>Executive Summary</h1> <pre><code>$ git push --delete &lt;remote_name&gt; &lt;branch_name&gt; $ git branch -d &lt;branch_name&gt; </code></pre> <p>Note that in most cases the remote name is <code>origin</code>.</p> <h1>Delete Local Branch</h1> <p>To delete the <em>local</em> branch use one of the following:</p> <pre><code>$ git branch -d branch_name $ git branch -D branch_name </code></pre> <p><strong>Note:</strong> The <code>-d</code> option is an alias for <code>--delete</code>, which only deletes the branch if it has already been fully merged in its upstream branch. You could also use <code>-D</code>, which is an alias for <code>--delete --force</code>, which deletes the branch "irrespective of its merged status." [Source: <code>man git-branch</code>] </p> <h1>Delete Remote Branch [Updated on 8-Sep-2017]</h1> <p>As of <a href="https://github.com/gitster/git/blob/master/Documentation/RelNotes/1.7.0.txt" rel="noreferrer">Git v1.7.0</a>, you can delete a <strong><em>remote</em></strong> branch using</p> <pre><code>$ git push &lt;remote_name&gt; --delete &lt;branch_name&gt; </code></pre> <p>which might be easier to remember than</p> <pre><code>$ git push &lt;remote_name&gt; :&lt;branch_name&gt; </code></pre> <p>which was added in <a href="https://github.com/gitster/git/blob/master/Documentation/RelNotes/1.5.0.txt" rel="noreferrer">Git v1.5.0</a> "to delete a remote branch or a tag."</p> <p>Starting on <a href="https://github.com/git/git/blob/master/Documentation/RelNotes/2.8.0.txt" rel="noreferrer">Git v2.8.0</a> you can also use <code>git push</code> with the <code>-d</code> option as an alias for <code>--delete</code>.</p> <p>Therefore, the version of Git you have installed will dictate whether you need to use the easier or harder syntax.</p> <h2>Delete Remote Branch [Original Answer from 5-Jan-2010]</h2> <p>From Chapter 3 of <a href="http://git-scm.com/book/en/Git-Branching-Remote-Branches" rel="noreferrer"><em>Pro Git</em></a> by Scott Chacon:</p> <blockquote> <h3>Deleting Remote Branches</h3> <p>Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s master branch (or whatever branch your stable codeline is in). You can delete a remote branch using the rather obtuse syntax <code>git push [remotename] :[branch]</code>. If you want to delete your serverfix branch from the server, you run the following:</p> <pre><code>$ git push origin :serverfix To git@github.com:schacon/simplegit.git - [deleted] serverfix </code></pre> <p>Boom. No more branch on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the <code>git push [remotename] [localbranch]:[remotebranch]</code> syntax that we went over a bit earlier. If you leave off the <code>[localbranch]</code> portion, then you’re basically saying, “Take nothing on my side and make it be <code>[remotebranch]</code>.”</p> </blockquote> <p>I issued <code>git push origin :bugfix</code> and it worked beautifully. Scott Chacon was right—I will want to <a href="http://en.wiktionary.org/wiki/dogear#Verb" rel="noreferrer">dog ear</a> that page (or virtually dog ear by answering this on Stack&nbsp;Overflow).</p> <p>Then you should execute this on other machines</p> <pre><code>git fetch --all --prune </code></pre> <p>to propagate changes.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload