{"id":367216,"date":"2021-11-15T15:30:12","date_gmt":"2021-11-15T12:30:12","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-clone-or-download-a-specific-branch-from-github-cloudsavvy-it\/"},"modified":"2021-11-15T15:30:12","modified_gmt":"2021-11-15T12:30:12","slug":"how-to-clone-or-download-a-specific-branch-from-github-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-clone-or-download-a-specific-branch-from-github-cloudsavvy-it\/","title":{"rendered":"#How to Clone or Download a Specific Branch from Github \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 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-6adf21d8cf8b9\" 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-6adf21d8cf8b9\" 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-clone-or-download-a-specific-branch-from-github-cloudsavvy-it\/#%E2%80%9CDownload_ZIP%E2%80%9D_Will_Work\" >\u201cDownload ZIP\u201d Will Work<\/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-clone-or-download-a-specific-branch-from-github-cloudsavvy-it\/#Cloning_A_Single_Branch_The_Right_Way\" >Cloning A Single Branch (The Right Way)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-clone-or-download-a-specific-branch-from-github-cloudsavvy-it\/#Fixing_a_Repo_Downloaded_From_Master_Branch\" >Fixing a Repo Downloaded From Master Branch<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Clone or <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">Download<\/a> a Specific Branch from Github \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-7125\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/10\/d6528811.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/10\/d6528811.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/10\/d6528811.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"700\" height=\"300\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Github is great for storing files, but sometimes the files you want are stored on a different Git branch, and aren\u2019t easily accessible from the main site. We\u2019ll show how to download and clone files from other branches.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"%E2%80%9CDownload_ZIP%E2%80%9D_Will_Work\"><\/span>\u201cDownload ZIP\u201d Will Work<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Github doesn\u2019t quite make the behaviour of their download feature very clear. If you swap to a different branch with the dropdown, you\u2019ll continuing viewing that branch, at least until you navigate away from the file viewer.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14701\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/aadac1d4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"494\" height=\"271\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>While on a branch, clicking \u201cDownload Zip\u201d from the Code dropdown will lead you to a download for the specific branch you\u2019re on. It doesn\u2019t tell you this on the site though, so you\u2019ll have to make sure that the filename for the download URL matches the correct branch, named in\u00a0<code>reponame-branchname.zip<\/code>\u00a0format.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14702\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/e8bb2301.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"539\" height=\"377\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The same goes for direct downloads via the \u201cRaw\u201d button\u2014they\u2019ll link to a specific branch, which you can change in the URL.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-14703\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/0ad2a42a-1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"400\" height=\"178\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<pre>https:\/\/raw.githubusercontent.com\/username\/Repo\/Branch\/readme.md<\/pre>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Cloning_A_Single_Branch_The_Right_Way\"><\/span>Cloning A Single Branch (The Right Way)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>However, downloading as a zip has a lot of downsides, and breaks Git history. You\u2019ll want to clone the branch using the <code>git clone<\/code>\u00a0command.<\/p>\n<p>You may have tried this only to find that you accidentally downloaded the <code>master<\/code>\u00a0branch. This is because, even if you\u2019re switched to a branch on the website, Github only gives you the\u00a0<em>URL<\/em> to download the repo from. It does not tell you\u00a0<em>how<\/em> you should download it.<\/p>\n<pre>https:\/\/github.com\/username\/Repo.git<\/pre>\n<p>If you take this URL, and run <code>git clone<\/code>, it will download the default branch, usually <code>master<\/code>. You can change this with some flags, usually done in one of two ways:<\/p>\n<pre>git clone --branch dev\u00a0https:\/\/github.com\/username\/Repo.git&#13;\n&#13;\ngit clone --branch dev --single-branch\u00a0https:\/\/github.com\/username\/Repo.git<\/pre>\n<p>The first will clone the entire repo, and checkout the <code>dev<\/code>\u00a0branch. The second, using the <code>--single-branch<\/code>\u00a0flag, will only fetch updates that pertain to the branch being downloaded. This can be faster if you have a lot of files on other branches you don\u2019t care about.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Fixing_a_Repo_Downloaded_From_Master_Branch\"><\/span>Fixing a Repo Downloaded From Master Branch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you\u2019re reading this because you already ran <code>git clone<\/code>\u00a0without the <code>--branch<\/code>\u00a0flag, don\u2019t worry, you can simply switch to the other branch:<\/p>\n<pre>git switch dev<\/pre>\n<p>If you made changes on the <code>master<\/code>\u00a0branch without realizing, you can move those changes to the new branch by using <code>git checkout<\/code>\u00a0instead with the <code>-b<\/code>\u00a0flag:<\/p>\n<pre>git checkout -b<\/pre>\n<p>You can also use <code>git stash<\/code>, which lets you store the changes and \u201cpop\u201d the stash open at a later time:<\/p>\n<pre>git stash&#13;\ngit switch dev&#13;\ngit stash pop<\/pre>\n<\/div>\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.cloudsavvyit.com\/14700\/how-to-clone-or-download-a-specific-branch-from-github\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Clone or Download a Specific Branch from Github \u2013 CloudSavvy IT&#8221; Github is great for storing files, but sometimes the files you want are stored on a different Git branch, and aren\u2019t easily accessible from the main site. We\u2019ll show how to download and clone files from other branches. \u201cDownload ZIP\u201d Will Work&#8230;<\/p>\n","protected":false},"author":1,"featured_media":367217,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/10\/d6528811.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-367216","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\/367216","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=367216"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/367216\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/367217"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=367216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=367216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=367216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}