Skip to content

Commit f8c434a

Browse files
author
Matthew McCullough
committed
Merge pull request #55 from randomecho/issue-43-delete-remote-branch
Adds instructions to delete remote branch
2 parents 7a564d8 + 7ad396a commit f8c434a

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

branching/index.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ <h4>
203203

204204
<p>If we want to delete a branch (such as the 'testing' branch in the
205205
previous example, since there is no unique work on it),
206-
we can run <code>git branch -d (branch)</code> to remove it.
206+
we can run <code>git branch -d (branch)</code> to remove it.</p>
207207

208208
<pre>
209209
<b>$ git branch</b>
@@ -215,6 +215,37 @@ <h4>
215215
* <span class="green">master</span>
216216
</pre>
217217

218+
<h4>
219+
git push (remote-name) :(branchname)
220+
<small>delete a remote branch</small>
221+
</h4>
222+
223+
<p>When you're done with a remote branch, whether it's been merged
224+
into the remote master or you want to abandon it and sweep it under
225+
the rug, you'll issue a <code>git push</code> command with a specially
226+
placed colon symbol to remove that branch.</p>
227+
228+
<pre>
229+
<b>$ git push origin :tidy-cutlery</b>
230+
To [email protected]:octocat/Spoon-Knife.git
231+
- [deleted] tidy-cutlery
232+
</pre>
233+
234+
<p>In the above example you've deleted the "tidy-cutlery" branch
235+
of the "origin" remote. A way to remember this is to think of the
236+
<code>git push remote-name local-branch:remote-branch</code> syntax.
237+
This states that you want to push your local branch to match that
238+
of the remote. When you remove the <code>local-branch</code> portion
239+
you're now matching nothing to the remote, effectively telling the
240+
remote branch to become nothing.
241+
</p>
242+
243+
<p>Alternatively, you can run
244+
<code>git push remote-name --delete branchname</code>
245+
which is a wrapper for the colon refspec (a <code>source:destination</code> pair)
246+
of deleting a remote branch.
247+
</p>
248+
218249
<p class="nutshell">
219250
<b>In a nutshell</b> you use <code>git branch</code> to list your
220251
current branches, create new branches and delete unnecessary or

0 commit comments

Comments
 (0)