{"id":389557,"date":"2022-01-04T22:00:18","date_gmt":"2022-01-04T19:00:18","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-delete-a-branch-on-github\/"},"modified":"2022-01-04T22:00:18","modified_gmt":"2022-01-04T19:00:18","slug":"how-to-delete-a-branch-on-github","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-delete-a-branch-on-github\/","title":{"rendered":"#How to Delete a Branch on GitHub"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a40a0d9edfbc\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a40a0d9edfbc\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-delete-a-branch-on-github\/#Delete_a_Branch_Using_GitHubs_Website_Remote_Branches_Only\" >Delete a Branch Using GitHub\u2019s Website (Remote Branches Only)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-delete-a-branch-on-github\/#Delete_a_Local_or_Remote_Branch_From_the_Command_Line\" >Delete a Local or Remote Branch From the Command Line<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Delete a Branch on GitHub&#8221;<\/strong><\/p>\n<div>\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-738302\" data-pagespeed-lazy-srcset=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/06\/GitHub-hero.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/06\/GitHub-hero.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/06\/GitHub-hero.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"GitHub logo on a pink gradient background\" width=\"1200\" height=\"675\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you\u2019re working in a repository with lots of activity, the number of branches that are created can quickly add up. Basic GitHub etiquette calls for you to delete merged branches or branches no longer required. Here\u2019s how.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Delete_a_Branch_Using_GitHubs_Website_Remote_Branches_Only\"><\/span><a rel=\"nofollow noopener\" target=\"_blank\" name=\"autotoc_anchor_0\">Delete a Branch Using GitHub\u2019s Website (Remote Branches Only)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can delete a branch using GitHub\u2019s website. However, you\u2019re only able to delete remote branches using this method\u2014you can\u2019t delete local branches from GitHub\u2019s website.<\/p>\n<p>To get started, visit the official GitHub website and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/login\">log in to your account<\/a>. Once logged in, select the repository that contains the branch you would like to delete from the left-hand pane.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-763905\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/10\/Select-a-repo..png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Select a repo.\" width=\"350\" height=\"275\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Next, click \u201cBranches\u201d below the header menu.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-763907\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/10\/Click-Branches..png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Click Branches.\" width=\"427\" height=\"298\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>A list of branches will appear. Locate the branch you\u2019d like to delete and then click the red trash can to the right of it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-763908\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/10\/Click-Delete..png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Click Delete.\" width=\"437\" height=\"242\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The branch is now deleted. To reflect this change in your local repository, change to the respective directory, checkout the <code>main<\/code>\u00a0branch, and then run the <code>git --pull<\/code>\u00a0command from the command line.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Delete_a_Local_or_Remote_Branch_From_the_Command_Line\"><\/span>Delete a Local or Remote Branch From the Command Line<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can delete both local and remote branches using the command line. First, open the command line of your choice, change to the directory of your GitHub repository (<code>cd &lt;repo-name&gt;<\/code>), and then checkout the <code>main<\/code>\u00a0branch by running the <code>git checkout &lt;feature-branch-name&gt;<\/code> command.<\/p>\n<p>There are two different commands you can run to delete a local branch. If it\u2019s already been merged, run:<\/p>\n<pre>git branch -d &lt;branch-name&gt;<\/pre>\n<p>Or, to force delete a branch regardless of its current status, run:<\/p>\n<pre>git branch -D &lt;branch-name&gt;<\/pre>\n<p>Just replace <code>&lt;branch-name&gt;<\/code> with the actual name of your branch. For example, if our branch name is test-branch, then we would run:<\/p>\n<pre>git branch -d test-branch<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-776113\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/The-command-to-delete-a-local-branch..png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The command to delete a local branch.\" width=\"521\" height=\"299\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The local branch is now deleted. If you\u2019re wanting to delete a remote branch, you will run:<\/p>\n<pre>git push &lt;remote-name&gt; --delete &lt;branch-name&gt;<\/pre>\n<p>Replace <code>&lt;remote-name&gt;<\/code> and <code>&lt;branch-name&gt;<\/code> with your own. For example:<\/p>\n<pre>git push origin --delete test-branch<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-776114\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/The-command-to-delete-a-remote-branch..png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The command to delete a remote branch.\" width=\"506\" height=\"222\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The remote branch is now deleted.<\/p>\n<p>If you\u2019re deleting branches in a GitHub repository that\u2019s no longer active or needed, you don\u2019t have to delete the branches one by one\u2014you can <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/716130\/how-to-delete-a-github-repository\/\">delete the entire repository.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Delete a GitHub Repository<\/em><\/strong><\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/753133\/how-to-delete-a-branch-on-github\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Delete a Branch on GitHub&#8221; If you\u2019re working in a repository with lots of activity, the number of branches that are created can quickly add up. Basic GitHub etiquette calls for you to delete merged branches or branches no longer required. Here\u2019s how. Delete a Branch Using GitHub\u2019s Website (Remote Branches Only) You&#8230;<\/p>\n","protected":false},"author":1,"featured_media":389558,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/06\/GitHub-hero.png?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-389557","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/389557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=389557"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/389557\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/389558"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=389557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=389557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=389557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}