
The contents of the page are stored as a blob in the repository, and it can be referenced in the tree from there. The GitHub API makes it pretty easy to write a single file to a repository with a commit: I also use node-fetch for making HTTP requests to other endpoints, which you can substitute for your preferred way of making those requests. This package is a pretty thin wrapper around GitHub’s V3 REST API, though, so the examples should translate to other environments. My code examples will be in JavaScript using the github-api NPM package to interact with the GitHub API.


Now I’m going to tell you how you can do it! It seemed like it would be a huge hassle, but it actually wasn’t as difficult as I expected.
GIT LFS SERVER HOW TO
The new site is keeping images in Netlify Large Media, so now I needed to figure out how to programmatically add files to my Git repo that were actually stored in Netlify’s Git LFS storage. Not so fast, though: the old version uploaded files straight to S3, which was also hosting the site. I just needed to update my Micropub implementation to be able to handle file uploads, which I had already supported in the previous version of my site. OwnYourGram uses Micropub to post entries, which is great: I’ve already implemented a Micropub endpoint for this site so I can post small text posts from Drafts. One of the ways I post content to this site is with OwnYourGram, which pulls the photos I post on Instagram and cross-posts them to my own site as well. So instead, I started storing media content in Git LFS using Netlify Large Media.

This can be an issue as a repository grows, since cloning a Git repository pulls down all of the history, even for files that were deleted in the current branch. I could have just stored it in Git with the rest of the content and simplified my life a bit, but then I would be worrying about bloating up my Git repository with binary files. When I started using Netlify and Gatsby for this site, I had to decide where to store media content that goes along with the site (mostly photos and other images).
