Selective syncing of a git repository subfolders

Hello everybody, I apologize in advance if this sounds as a silly question. I looked for an answer everywhere but I can’t find it: so if you don’t have time to reply, a link to an article will be welcome and very useful anyway.

Let’s get to the point: I’m using GitHub to store the source code of my website. It’s getting quite big, and I’d even like to add a gallery of images, which will make it even bigger. I fear on the long run it will become too large for my computer, and having the whole repository on my computer may become a problem of storage. Is there a way to “selectively” sync which folder to keep locally, while keeping the “heavy” subfolders of the repository (namely the ones containing images and large files) on the remote origin (only on GitHub). Is it possible to do so? Is it absurd?

Thanks a lot!

Hello @xplosionmind and welcome to the community.

I don’t think this is a silly question at all :grinning: On the other hand, I don’t think that this is exclusively a git or GitHub question …

git, as a tool, is specifically designed to handle versioning text files. Out of necessity, it will version binary files such as images also but isn’t optimized for those types of files. So, in your hypothetical situation, not only will you run into a problem of storage on your local computer but you’ll increasingly run into a problem where git doesn’t handle well the types of files you’re asking it to deal with.

Because of this, I would store the large files someplace else such as Amazon’s S3 or Azure Blob Storage. Then, I would have your website make those large files directly available from whichever cloud storage location you select.

It will definitely make things a little more complex to keep track of. But on the other hand, you’ll be storing the differing file types in systems that were optimized for those different requirements.

Let us know if you have more questions.

1 Like

Thanks a lot, you’ve been very helpful!

1 Like