0

During development of my php-app I've stored all data that the app produces within the app-folder and hence the data being part of my git-repo. The root of the repo is also the webroot. This has worked well for me during the beginning of development and it sort of made sense at the time to commit the app together with the data.

But I feel this needs to be redone now for several reasons. One being that the data-size is getting too big for me to comfortable store it in the git-repo. Another is that I simply do not need to have a snapshot of the data for a given commit. The main-reason, I guess is that I've deployed my app to my NAS(synology) for real use, and I push commits to it via webdav. And to my knowledge of git, it's not possible or at least not practical to do pushes while leaving certain data in the remote-repo untouched.

Also, it would be nice though not necessary if both the app on the nas and the app on my computer, while testing has access to the same data-directory. This made me think of moving the data out from the app-directory and access it via ftp. But I'm not sure that would be a good idea, especially since all the "real" access to the files would be from the very same device, the nas.

What would be a good structure and file access methods etc for this?

Clox
  • 1,923
  • 5
  • 28
  • 43
  • Now that I think about it I'm guessing the ftp-part really doesn't make sense. I would be better to detect where the app is run from and set path to the data directory accordingly and from my computer it would access the folder through nfs or such, seamlessly without any further changes to the app. – Clox Nov 18 '14 at 11:34

1 Answers1

1

I always keep my data in a separate directory which I take out of git with a .gitignore file. This means that when I push changes I am not overwriting the live data.

If I need fresh data to test on I use ftp to download a new version of the data directory from the live server to my development server.

This works for me because most of the data is uploaded by users so it quickly gets out of sync with my development copy and I don't want to overwrite it. It also means that I can't accidentally corrupt their data with a mistake in development.

Mark_1
  • 623
  • 6
  • 16
  • Ah, sounds good and simple. One tiny complaint though, I have put .gitkeep-files in the subdirectories of the data-folder so that if I were to clone the repo and start fresh with no data so to speak, the data-folder would still be correctly structured. Is there any way of doing this easily while ignoring the folder at the same time? – Clox Nov 18 '14 at 12:59
  • You may find what you want [in this answer](http://stackoverflow.com/questions/7229885/what-are-the-differences-between-gitignore-and-gitkeep) This answer looks like it might match your needs; `If you want an empty dir and make sure it stays 'clean' for git, create a .gitignore containing the following lines within: # .gitignore sample #ignore all files in this dir... * #... except for this one. !.gitignore` Sorry this looks awful, I am a novice at mini-Markdown – Mark_1 Nov 18 '14 at 13:28
  • Thank you. I've got it all set up now.It's probably a better idea to edit your answer and add code there rather than putting codes in comments, they are quite limited. Also, you can get the direct url to an answer by clicking its "share"-button. I'm marking your answer as accepted. Cheers! This answer has some more relevant info: http://stackoverflow.com/a/19005115/147949 – Clox Nov 18 '14 at 14:52