203
203
204
204
< p > If we want to delete a branch (such as the 'testing' branch in the
205
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
207
208
208
< pre >
209
209
< b > $ git branch</ b >
@@ -215,6 +215,37 @@ <h4>
215
215
* < span class ="green "> master</ span >
216
216
</ pre >
217
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 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
+
218
249
< p class ="nutshell ">
219
250
< b > In a nutshell</ b > you use < code > git branch</ code > to list your
220
251
current branches, create new branches and delete unnecessary or
0 commit comments