What should I include in my repository?

Dear all,

I’m still new to Git but I’m planning to use / start learning it. I have a VPS server that hosts a live and test site. I have a laptop which serves as a development machine.

My setup idea: develop on laptop, push to a Git server that resides on the VPS server. Pull updates from Git server to both test - and live server.

First question: would this be a good setup?

Second question: the actual files that will be modified / developed reside in 1 seperate directory. The root directory contains a Joomla installation that is seperated from my own code. My own code belongs to the same project / website as the Joomla pages, but technically they are seperated as I don’t want to rely on Joomla. As Joomla is server dependent (i.e. every host has it’s own Joomla files and database), I’m wondering if I should exclude all Joomla folders and files residing in the root directory of my project by using the .gitignore file? What are best practise rules here? Am I thinking in the right direction?

Thanks and kind regards, J.

Hi @jpostema81,

Your described plan sounds good. You can host your own Git server on a VPS or you can use GitHub as your Git server. I would recommend using different branches for test and production so that you can always keep your production code clean and only merge the test branch in when it has passed your tests.

As for Joomla, if you want to keep your project separate, I would definitely add all Joomla files to the .gitignore file as well as any databases, private files, or environment specific files.

Thanks!

Hello @that-pat,

first of all, thanks for your extensive reply, this is really appreciated!

I think I will exclude the Joomla folder content. But I got another question / problem: there are mainly two users working on the project: me as a PHP developer and the project owner. The latter is only doing minor changes like adding and removing images or movies, no actual code editing / development.

The problem I foresee is, if i’m correct, that everyone working on the project should access (use) the project files exclusively by git rather than through the filesystem. (ftp client in this case) As the product owner has no experience with using git (he is not a software developer), I’m wondering if git could become a barrier and will confuse him.

Are my concerns legitime and if so are there any ways to overcome these problems?

Kind regards,

J.

Hi @jpostema81,

That could definitely be a problem, but it’s not insurmountable. If they are open to learning Git, then something like the GitHub Learning Lab could be a user friendly way of teaching them things about Git. There are numerous other great courses as well.

If they don’t want to learn Git and you would like to have them in an environment that is more comfortable for people who don’t edit code super often, having them submit their changes and edits as Pull Requests can be really helpful too as it allows you to keep everything in Git, provides a decent user interface for people who would like to avoid the command line, and lets you review any code that the product owner submits before merging it in to your production instance.

Thanks!

Hi,

thanks again for your helpful reply! I will try to start using Git pull requests.

Just one more question about my setup as I described in my first post:

“My setup idea: develop on laptop, push to a Git server that resides on the VPS server. Pull updates from Git server to both test - and live server.”

As I gained some more experience using Git I start thinking the above mentioned setup is not optimal as it uses Git as a deployment tool: the pulling from the Git server to the live website location (in this case they both reside on the same server). I’m just wondering what would be the benefit of pulling it to the live server instead of doing for instance a rsync at file system level rather than syncing at git level as the repo at the live server is only used for pulling? I hope my question makes sense…

Hi @jpostema81,

The biggest benefit that I see to using Git instead of rsync in this scenario is the ease of being able to roll back to an earlier stable commit if something happens. Using a test server, you shouldn’t have any unforeseen problems but I know from experience how easy it can be to make a mistake and need to roll back in a hurry, even with careful planning.

After all, we’re human and mistakes happen, right?

I hope this helps!