diff --git a/branching/index.html b/branching/index.html index 198bb70..6bea373 100644 --- a/branching/index.html +++ b/branching/index.html @@ -203,7 +203,7 @@ README hello.rb more.txt test.txt

If we want to delete a branch (such as the 'testing' branch in the previous example, since there is no unique work on it), - we can run git branch -d (branch) to remove it. + we can run git branch -d (branch) to remove it.

 $ git branch
@@ -215,6 +215,37 @@ Deleted branch testing (was 78b2670).
 * master
 
+

+ git push (remote-name) :(branchname) + delete a remote branch +

+ +

When you're done with a remote branch, whether it's been merged + into the remote master or you want to abandon it and sweep it under + the rug, you'll issue a git push command with a specially + placed colon symbol to remove that branch.

+ +
+$ git push origin :tidy-cutlery
+To git@github.com:octocat/Spoon-Knife.git
+ - [deleted]         tidy-cutlery
+
+ +

In the above example you've deleted the "tidy-cutlery" branch + of the "origin" remote. A way to remember this is to think of the + git push remote-name local-branch:remote-branch syntax. + This states that you want to push your local branch to match that + of the remote. When you remove the local-branch portion + you're now matching nothing to the remote, effectively telling the + remote branch to become nothing. +

+ +

Alternatively, you can run + git push remote-name --delete branchname + which is a wrapper for the colon refspec (a source:destination pair) + of deleting a remote branch. +

+

In a nutshell you use git branch to list your current branches, create new branches and delete unnecessary or