Skip to content

Commit d957495

Browse files
committed
Adds instructions to delete remote branch
Syntax to delete remote branch is not the same as a local one. Introduces the syntax mentioned in the book and throws in the easier to remember one to boot. Requested by, fixes #43 References: - http://git-scm.com/book/en/Git-Branching-Remote-Branches - http://stackoverflow.com/questions/2003505/delete-remote-branch
1 parent 7a564d8 commit d957495

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

branching/index.html

Lines changed: 31 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,36 @@ <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 special
226+
colon to nuke 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 also run
244+
<code>git push remote-name --delete branchname</code>
245+
which is basically a wrapper for the above colon prefix version.
246+
</p>
247+
218248
<p class="nutshell">
219249
<b>In a nutshell</b> you use <code>git branch</code> to list your
220250
current branches, create new branches and delete unnecessary or

0 commit comments

Comments
 (0)