{"id":6786,"date":"2020-02-18T16:11:50","date_gmt":"2020-02-18T11:11:50","guid":{"rendered":"https:\/\/ahmadawais.com\/?p=6786"},"modified":"2020-02-18T16:13:44","modified_gmt":"2020-02-18T11:13:44","slug":"shallow-clone-large-git-repository","status":"publish","type":"post","link":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/","title":{"rendered":"Shallow Clone a Large Git Repository Quickly"},"content":{"rendered":"<p>Say you have a large git repository say 1 GB or even bigger. It may have a lot of branches and a long history. You now want to clone it to make some changes and create a pull request. Cloning it in its entirety with <code>git clone<\/code> would be a bad idea. Instead, do this:<\/p>\n<pre class=\"lang:bash\">git clone -b &lt;branch&gt; &lt;url&gt; --depth=1<\/pre>\n<p>A practical example would be:<\/p>\n<pre class=\"lang:bash\">git clone -b master https:\/\/github.com\/gatsbyjs\/gatsby --depth=1<\/pre>\n<p>The giant <span class=\"num text-emphasized\">735.03<\/span> MB Gatsby repository, cloned this way is about 680 MB in size. I read that Jira is 677MB, with the working directory being another 320MB, when you clone this way.<\/p>\n<h3 id=\"explanation\">Explanation:<a href=\"#explanation\" class=\"heading-link\">#<\/a><\/h3>\n<ul>\n<li><code>-b &lt;branch&gt;<\/code> to define the exact branch you want to clone<\/li>\n<li><code>--depth=n<\/code> to pull down only the latest <code>n<\/code> commits<\/li>\n<\/ul>\n<p>You can work this magic when pulling down the code as well:<\/p>\n<pre class=\"lang:bash\">git pull --rebase origin &lt;branch&gt; --depth=1<\/pre>\n<p>A practical example would be:<\/p>\n<pre class=\"lang:bash\">git pull --rebase origin master --depth=1<\/pre>\n<p>That&#8217;s about it. You are now shallow cloning and pulling your git repo. It doesn&#8217;t make that huge of an impact but I like to stay minimal as far as I can.<\/p>\n<p>Use your code for good.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to git shallow clone in case of big git repositories and only download the latest n commits from a single branch you specify.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"webmentions_disabled_pings":false,"webmentions_disabled":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9,215],"tags":[255,256],"class_list":["post-6786","post","type-post","status-publish","format-standard","hentry","category-tutorials","category-web","tag-git-clone","tag-git-shallow-clone"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Shallow Clone a Large Git Repository Quickly<\/title>\n<meta name=\"description\" content=\"Learn how to git shallow clone in case of big git repositories and only download the latest n commits from a single branch you specify.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Shallow Clone a Large Git Repository Quickly\" \/>\n<meta property=\"og:description\" content=\"Learn how to git shallow clone in case of big git repositories and only download the latest n commits from a single branch you specify.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/\" \/>\n<meta property=\"og:site_name\" content=\"Ahmad Awais\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/AhmadAwais\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/AhmadAwais\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-18T11:11:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-02-18T11:13:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ahmadawais.com\/wp-content\/uploads\/2024\/08\/ahmad-awais.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1440\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ahmad Awais\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MrAhmadAwais\" \/>\n<meta name=\"twitter:site\" content=\"@MrAhmadAwais\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ahmad Awais\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/\"},\"author\":{\"name\":\"Ahmad Awais\",\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/#\\\/schema\\\/person\\\/1d1b9504182dca2315cf039fb4ebb85b\"},\"headline\":\"Shallow Clone a Large Git Repository Quickly\",\"datePublished\":\"2020-02-18T11:11:50+00:00\",\"dateModified\":\"2020-02-18T11:13:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/\"},\"wordCount\":168,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/#\\\/schema\\\/person\\\/1d1b9504182dca2315cf039fb4ebb85b\"},\"keywords\":[\"git clone\",\"git shallow clone\"],\"articleSection\":[\"Tutorials\",\"Web\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/\",\"url\":\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/\",\"name\":\"Shallow Clone a Large Git Repository Quickly\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/#website\"},\"datePublished\":\"2020-02-18T11:11:50+00:00\",\"dateModified\":\"2020-02-18T11:13:44+00:00\",\"description\":\"Learn how to git shallow clone in case of big git repositories and only download the latest n commits from a single branch you specify.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/shallow-clone-large-git-repository\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ahmadawais.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Shallow Clone a Large Git Repository Quickly\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/#website\",\"url\":\"https:\\\/\\\/ahmadawais.com\\\/\",\"name\":\"Ahmad Awais\",\"description\":\"Founder &amp; CEO of CommandCode.ai f\\\/k\\\/a Langbase | Google Developers Advisory Board (gDAB) founding member\",\"publisher\":{\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/#\\\/schema\\\/person\\\/1d1b9504182dca2315cf039fb4ebb85b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ahmadawais.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/#\\\/schema\\\/person\\\/1d1b9504182dca2315cf039fb4ebb85b\",\"name\":\"Ahmad Awais\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Ahmad-Awais-face.jpg\",\"url\":\"https:\\\/\\\/ahmadawais.com\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Ahmad-Awais-face.jpg\",\"contentUrl\":\"https:\\\/\\\/ahmadawais.com\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Ahmad-Awais-face.jpg\",\"width\":2299,\"height\":1705,\"caption\":\"Ahmad Awais\"},\"logo\":{\"@id\":\"https:\\\/\\\/ahmadawais.com\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Ahmad-Awais-face.jpg\"},\"description\":\"Founder & CEO of \u2318 Command Code coding agent with taste. Founded Langbase.com, AI cloud to build, deploy, and scale AI agents with tools & memory \u00b7 Creator of Command.new. \\\"Awais is an awesome example for developers\\\" \u2014 Satya Nadella, CEO of Microsoft. NASA Mars Ingenuity Helicopter mission code contributor 8th GitHub Stars Award recipient with 5x GitHub Stars Award (Listed as GitHub's #1 JavaScript trending developer). Google Developers Expert Web DevRel. Ex VP Eng (DevTools & DevRel) Rapid \u00b7 Google Developers Advisory Board (gDAB) founding member \u00b7 AI\\\/ML\\\/DevTools Angel Investor (Replit, Resend, Daytona, Gumroad and you?) \u276f AI\\\/ML Advisory Board San Francisco, DevNetwork. Award-winning Open Source Engineering leader authored hundreds of open-source dev-tools and software libraries used by millions of developers, including Shades of Purple code theme and corona-cli. Linux Foundation (Node.js Committee Lead), OpenAPI Business Governing Board. Taught 108K+ developers via NodeCLI.com and VSCode.pro course. 274 million views, blogging for 24 yrs. \u276f Read more about Ahmad Awais or come say hi on \ud835\udd4f @MrAhmadAwais.\",\"sameAs\":[\"https:\\\/\\\/AhmadAwais.com\\\/\",\"https:\\\/\\\/facebook.com\\\/AhmadAwais\",\"https:\\\/\\\/instagram.com\\\/MrAhmadAwais\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/MrAhmadAwais\\\/\",\"https:\\\/\\\/x.com\\\/MrAhmadAwais\",\"https:\\\/\\\/youtube.com\\\/AhmadAwais\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Shallow Clone a Large Git Repository Quickly","description":"Learn how to git shallow clone in case of big git repositories and only download the latest n commits from a single branch you specify.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/","og_locale":"en_US","og_type":"article","og_title":"Shallow Clone a Large Git Repository Quickly","og_description":"Learn how to git shallow clone in case of big git repositories and only download the latest n commits from a single branch you specify.","og_url":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/","og_site_name":"Ahmad Awais","article_publisher":"https:\/\/facebook.com\/AhmadAwais","article_author":"https:\/\/facebook.com\/AhmadAwais","article_published_time":"2020-02-18T11:11:50+00:00","article_modified_time":"2020-02-18T11:13:44+00:00","og_image":[{"width":2560,"height":1440,"url":"https:\/\/ahmadawais.com\/wp-content\/uploads\/2024\/08\/ahmad-awais.jpg","type":"image\/jpeg"}],"author":"Ahmad Awais","twitter_card":"summary_large_image","twitter_creator":"@MrAhmadAwais","twitter_site":"@MrAhmadAwais","twitter_misc":{"Written by":"Ahmad Awais","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/#article","isPartOf":{"@id":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/"},"author":{"name":"Ahmad Awais","@id":"https:\/\/ahmadawais.com\/#\/schema\/person\/1d1b9504182dca2315cf039fb4ebb85b"},"headline":"Shallow Clone a Large Git Repository Quickly","datePublished":"2020-02-18T11:11:50+00:00","dateModified":"2020-02-18T11:13:44+00:00","mainEntityOfPage":{"@id":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/"},"wordCount":168,"commentCount":0,"publisher":{"@id":"https:\/\/ahmadawais.com\/#\/schema\/person\/1d1b9504182dca2315cf039fb4ebb85b"},"keywords":["git clone","git shallow clone"],"articleSection":["Tutorials","Web"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/","url":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/","name":"Shallow Clone a Large Git Repository Quickly","isPartOf":{"@id":"https:\/\/ahmadawais.com\/#website"},"datePublished":"2020-02-18T11:11:50+00:00","dateModified":"2020-02-18T11:13:44+00:00","description":"Learn how to git shallow clone in case of big git repositories and only download the latest n commits from a single branch you specify.","breadcrumb":{"@id":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ahmadawais.com\/shallow-clone-large-git-repository\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ahmadawais.com\/"},{"@type":"ListItem","position":2,"name":"Shallow Clone a Large Git Repository Quickly"}]},{"@type":"WebSite","@id":"https:\/\/ahmadawais.com\/#website","url":"https:\/\/ahmadawais.com\/","name":"Ahmad Awais","description":"Founder &amp; CEO of CommandCode.ai f\/k\/a Langbase | Google Developers Advisory Board (gDAB) founding member","publisher":{"@id":"https:\/\/ahmadawais.com\/#\/schema\/person\/1d1b9504182dca2315cf039fb4ebb85b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ahmadawais.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/ahmadawais.com\/#\/schema\/person\/1d1b9504182dca2315cf039fb4ebb85b","name":"Ahmad Awais","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ahmadawais.com\/wp-content\/uploads\/2020\/06\/Ahmad-Awais-face.jpg","url":"https:\/\/ahmadawais.com\/wp-content\/uploads\/2020\/06\/Ahmad-Awais-face.jpg","contentUrl":"https:\/\/ahmadawais.com\/wp-content\/uploads\/2020\/06\/Ahmad-Awais-face.jpg","width":2299,"height":1705,"caption":"Ahmad Awais"},"logo":{"@id":"https:\/\/ahmadawais.com\/wp-content\/uploads\/2020\/06\/Ahmad-Awais-face.jpg"},"description":"Founder & CEO of \u2318 Command Code coding agent with taste. Founded Langbase.com, AI cloud to build, deploy, and scale AI agents with tools & memory \u00b7 Creator of Command.new. \"Awais is an awesome example for developers\" \u2014 Satya Nadella, CEO of Microsoft. NASA Mars Ingenuity Helicopter mission code contributor 8th GitHub Stars Award recipient with 5x GitHub Stars Award (Listed as GitHub's #1 JavaScript trending developer). Google Developers Expert Web DevRel. Ex VP Eng (DevTools & DevRel) Rapid \u00b7 Google Developers Advisory Board (gDAB) founding member \u00b7 AI\/ML\/DevTools Angel Investor (Replit, Resend, Daytona, Gumroad and you?) \u276f AI\/ML Advisory Board San Francisco, DevNetwork. Award-winning Open Source Engineering leader authored hundreds of open-source dev-tools and software libraries used by millions of developers, including Shades of Purple code theme and corona-cli. Linux Foundation (Node.js Committee Lead), OpenAPI Business Governing Board. Taught 108K+ developers via NodeCLI.com and VSCode.pro course. 274 million views, blogging for 24 yrs. \u276f Read more about Ahmad Awais or come say hi on \ud835\udd4f @MrAhmadAwais.","sameAs":["https:\/\/AhmadAwais.com\/","https:\/\/facebook.com\/AhmadAwais","https:\/\/instagram.com\/MrAhmadAwais\/","https:\/\/www.linkedin.com\/in\/MrAhmadAwais\/","https:\/\/x.com\/MrAhmadAwais","https:\/\/youtube.com\/AhmadAwais"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/posts\/6786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/comments?post=6786"}],"version-history":[{"count":4,"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/posts\/6786\/revisions"}],"predecessor-version":[{"id":6790,"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/posts\/6786\/revisions\/6790"}],"wp:attachment":[{"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/media?parent=6786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/categories?post=6786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahmadawais.com\/api\/wp\/v2\/tags?post=6786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}