Determining Which Folders in craft/storage to Add to .gitignore
This article was written for Craft 2. Craft 3 projects can safely use the default storage/.gitignore file as a starting point.
There’s a lot going on witin your craft/storage/ folder. Let’s go through it all one-by-one and figure out what, if any, would be missed if it went missing, versus what can safely be .gitignore’d.
Keeping database backups is important, but unless you are planning on keeping everyone’s databases in sync, there’s probably not a whole lot of reason why you’d want to store them in version control.
If you’re running Craft Pro and you’ve uploaded a custom Login Page Logo or Site Icon, this is where those files will be stored. There’s no corresponding database value to worry about either.
Verdict: Don’t ignore
Everything in this folder can be recreated in a pinch, and much of it is constantly being regenerated anyway. There’s no compelling reason to keep any of it in version control, and there are good reasons not to. In fact, Craft actually creates a .gitignore file within craft/storage/runtime/ for you, telling Git to ignore everything in the folder but itself (the .gitignore file). So you don’t really have to worry about this one.
It might seem like a no-brainer that user photos should get added to version control, but keep in mind that when a user uploads a photo, the file is saved in this folder and its filename is saved to the user’s row in the database’s ‘users’ table. So unless you have a way to keep the databases in sync between servers, there’s not a whole lot of point to sharing these files. You might be better off keeping them out of version control, and just manually FTP’ing this folder over to the new server when you’re first setting it up.
At the end of the day, the only folder that really might be worth putting in version control is craft/storage/rebrand. And that’s assuming you have Craft Pro. Otherwise, you might as well just .gitignore the craft/storage/ folder as a whole, and call it a day.