{"id":301,"date":"2021-03-02T00:35:58","date_gmt":"2021-03-02T05:35:58","guid":{"rendered":"http:\/\/myblog.vindaloo.com\/?p=301"},"modified":"2021-04-27T23:33:03","modified_gmt":"2021-04-28T04:33:03","slug":"git-sparse-checkout","status":"publish","type":"post","link":"http:\/\/myblog.vindaloo.com\/?p=301","title":{"rendered":"Git Sparse Checkout"},"content":{"rendered":"\n<p>Git Sparse Checkout<\/p>\n\n\n\n<p>At work we had a very large monorepo. I&#8217;m tempted to quote Douglas Adams here but the reference is good enough. Checking out the whole thing runs the possibility of confusing git status messages as a result changes in the other part of the tree. These messages are a distraction. Dealing with them can consume large amounts of time. The best way to avoid them perform what&#8217;s called a sparse checkout. This is a checkout that only puts what you need into your working directory. In a normal checkout:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> $ git clone ...\n<\/pre>\n\n\n\n<p>You get the entire code base in your working directory. A sparse checkout is more complicated to perform:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> $ mkdir _target directory_\n $ cd _target directory_\n $ git init .\n $ git config core.sparsecheckout true\n $ echo \"_your desired subdir_\" &gt;&gt; .git\/info\/sparse-checkout\n $ ## Repeat the echo for each directory you need.\n $ git remote add origin https:\/\/git.neopost.com\/PPT\/IBMHSM.git\n $ git fetch\n $ git checkout master<\/pre>\n\n\n\n<p>It&#8217;s eight steps but if you do it this way, you gain complete control over what&#8217;s in your working directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git Sparse Checkout At work we had a very large monorepo. I&#8217;m tempted to quote Douglas Adams here but the reference is good enough. Checking out the whole thing runs the possibility of confusing git status messages as a result changes in the other part of the tree. These messages are a distraction. Dealing with &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/myblog.vindaloo.com\/?p=301\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Git Sparse Checkout&#8221;<\/span><\/a><\/p>\n","protected":false},"author":54,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-301","post","type-post","status-publish","format-standard","hentry","category-open-source"],"_links":{"self":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/users\/54"}],"replies":[{"embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301"}],"version-history":[{"count":3,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":306,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts\/301\/revisions\/306"}],"wp:attachment":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}