I started using git with my .git directory and everything else inside the web root. After further reading it seems this is a bad practice. I’m now placing my application and system folders outside the web root. The only thing left in my web root will be an index file and an asset folder for images, js and css.
Old way
/var/www/assets
/var/www/application
/var/www/system
/var/www/.git
New way (Not really sure where the .git should go with this?)
/var/www/assets
/var/application
/var/system
Before it was easy to set up git. I created the repo and it found all the files because they were all in the same directory. Now, I’m not really that sure where the .git repo should reside in the new structure. If I add it to the /var/www it sees the assets folder but not anything else.
I want to manage all three directories with git. How do I include all the directories into the repo. Or, is there another way that git is designed to handle such instances? I found another question like this on this site, but I couldn’t make sense of it.
Also, on my remote repo I will have it set up like so. I haven’t moved any of the directories around yet. I’ve just been trying to get it to work locally first.
var/www/assets
var/application
var/system
var/git/.git
Instead of moving the two directories out of the repo, I’d suggest moving the web root stuff into a
wwwdirectory. The way I’d do it is something like the following:Create a new web root directory:
So, the current temporary structure is:
You have two choices at this point: either edit your server config to make
/var/www/wwwthe new web root. Or move the whole thing somewhere else and symlink the webroot to its original location. I personally prefer the second option:Now your folder structure is:
But the web serever only sees:
Doing it this way ensures that your project is always under git control with no changes happening outside of git (and thus unrecorded in git’s history). This also has the advantage that you don’t need to change the remote repo at all. Just push your changes there.
If you want your app to be installable by others correctly using the symlink method you can always provide a shell script to create the symlink for them and make sure the server configs are correct.