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
Soon Van committed
Dec 31, 2012 at 01:13 UTC
d9574958d4129f7fb01c67fd6dc28222be9fc9c3
1 file changed
+31
-1
branching/index.html
+31
-1
@@ -203,7 +203,7 @@ README hello.rb more.txt test.txt
203
204
<p>If we want to delete a branch (such as the 'testing' branch in the
205
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>
207
208
<pre>
209
<b>$ git branch</b>
@@ -215,6 +215,36 @@ Deleted branch testing (was 78b2670).
215
* <span class="green">master</span>
216
</pre>
217
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 git@github.com: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
+
248
<p class="nutshell">
249
<b>In a nutshell</b> you use <code>git branch</code> to list your
250
current branches, create new branches and delete unnecessary or