To commit or not commit. A list of reasons and resources to support your decision.
Generally speaking, I say no — don't commit and store images in your git repository. However, I understand why many developers choose to use git to track and store images.
In fact, there are some projects in which I have a number of images tracked with git. But generally, if I can avoid it, I do.
I avoid committing images (or any media files) to my git repositories for these reasons:
That said, committing images to your repo can come with benefits:
Here are a number of options when you want to avoid committing images to your repo.
Services like Cloudinary and Imgix are amazing alternatives that make it easy to move images out of your repository. They both also have optimized delivery APIs that provide real-time transformations and effects.
In some cases, these services require that you bring a hosting service, like AWS S3. That can seem intimidating at first. But once you get the hang of it, it'll feel like working with any other service. Especially when paired with a tool like Transmit to make it easy to upload images.
If your content is already in a CMS, great! If not, you may want to consider if it'd be beneficial to move all your content into a CMS, and then take advantage of the CMS's media-specific features. For example, Contentful has an image delivery API that provides transformations on the fly.
Services like Dropbox could easily be used. You can even have public links for these images.
The biggest downside when compared to the others is that there is no transforming images on the fly.
Last, I have a theory that GitHub issues could become your image host. (Although this is not proven.)
If you do decide to continue committing images, I'll leave you with these final thoughts.
Consider first using git submodules. This can be a clean way to wipe history and start over, or simply avoid downloading the images unless they are relevant to what you're working on.
If you're going to commit images, use SVG files as much as reasonably possible. SVG files are venctor images (which means they scale very well), but they are also plain text files. This means git can track the changes on the file and not a new copy of the file each time.
I hope you now have the confidence necessary to either commit or not commit your image assets.