{
  "path": "/posts/git-download-subpath",
  "site": "at://did:plc:ephkzpinhaqcabtkugtbzrwu/site.standard.publication/3mdogbputbg2m",
  "$type": "site.standard.document",
  "title": "git download-subpath",
  "description": "I made a git helper tool that lets you retrieve files from a subpath of git without downloading the whole of the (possibly huge) repo.",
  "publishedAt": "2024-05-14T12:08:10.000Z",
  "textContent": "My blog has ~250MB of photos in it (as I archived my Instagram here — _a decade_ of photos) which means that every time I want some files from my blog's repo I've needed to pull down all that data to get at the few files I want.\n\nThis isn't a problem on my laptop where I work on my blog (as it's already cloned), but I also keep my IndieKit config in there, which I need to copy to the server it runs from. I don't want to have to download hundreds of MB (and growing!) of photo data every time I want to update it.\n\nSo I built git-download-subpath, which is a bash script around git's partial clone functionality.\n\nThis script (which you can find & download below) completes these steps:\n\n1. Clones a \"no tree\" copy of the repo to a temporary directory (just references to commits & the latest files, not the data itself)\n2. Completes a \"no cone\" sparse checkout of the subpath desired\n3. Moves that desired subpath over the working directory (or the destination, if specified)\n\nI'm no bash expert, so there may be subtle bugs here; let me know if you spot them!\n\n_Copy the following bash to git-download-subpath somewhere in your $PATH (I keep it in /usr/local/bin), and mark as executable with chmod +x git-download-subpath:_",
  "canonicalUrl": "https://www.byjp.me/posts/git-download-subpath"
}