5

I have a joomla website on a remote server that I am constantly developing. To debug it, I need to have a local copy, but this creates a version problem:

Sometimes I debug and modify the local version, afterwards some changes were made to the remote website(install extension, update content, etc.). Then if I want to do further debugging, I have to download the website to local again. This is very inconvenient.

I know Git is good at version control. Can I use it to keep my local website and remote website synchronized? Or is there any other common practice for this?

  • 2
    The short answer is yes, but it involves a lot more than just installing and using GIT. You'll need a fundamental understanding of creating, managing, merging and pushing code. Even at that you'll need either a hosted solution with repository hooks or know how to set-up remote git instances, and program the hooks to respond to GIT activity putting the appropriate code where it should be based on branch. Point being, are you willing to take on that many unknowns to achieve your end goal? – Brian Bolli Mar 17 '16 at 2:25
  • Although Git is a must learn thing, what you said is a little too much for me. My end goal is just to debug joomla sites, but to debug it, I have to have a local version and encounter the version problem. Is there any solution for this? – shenkwen Mar 17 '16 at 2:48
  • Just GIT is actually a great place to start, I'll put together an answer with a focus on git. – Brian Bolli Mar 17 '16 at 2:51
  • @BrianBolli I am still waiting for your answer. In the past week I was getting myself familiar with Github, and found that Github actually does similar things. It registers any local change and sync them to the remote project hosted by Github. Is it possible to achieve my goal through Github? – shenkwen Mar 22 '16 at 13:40
  • Github will work fine, but you're conflating the roles of the code repository and code deployments in the devops workflow you're working on. Will post an answer today, but repositories help manage multiple application states. The tasks of deploying the different code states to the appropriate servers (i.e. production, staging, development) is a whole different critter. – Brian Bolli Mar 22 '16 at 14:34
8

There are two concepts we're dealing with, the first being a code repository. Although there are different types of repository technologies, GIT is the defacto standard currently. Websites such as Github and Bitbucket are popular web services offering free GIT hosting solutions. The key point here being GIT is the actual underlying technology, and will need to be installed on your development box; and Github and Bitbucket are web hosted implementations of GIT.

The proper utilization of GIT and all its features are beyond the scope of this answer, but the primary concept of branches is critical to what you are trying to do. When you create a new project and accompanying GIT repository, you have only one branch, master. This branch would represent the production state of your application. In addition to this, you would create a staging branch. In most development firms this would a secondary server where clients and developers can test code being prepped for release to production. In your case however, this staging state would represent your local development box.

So the developer workflow would be to make changes locally to the staging branch and commit the changes to their local GIT instance and subsequently push the changes back to origin (aka Github or Bitbucket).

This brings us to our second concept, deployment. The repository will manage the various application states, but there is still the issue of distributing these states to the correct servers. There are many options to do this. You could sFTP files locally to the correct server, use Cloud hosting solution provided repository hooks, or code custom hooks on custom remote GIT instance on server. How you should approach this depends on how and where you are hosting the website.

Your hunch that "there has to be a better way" is spot on. You will probably run into many more questions as you start to implement, but the best way to learn them is to attempt to apply to your workflows and continue asking questions.

I anticipate some back and forth on this as there's a lot of information here.

1) Consolidate all code changes, so the files and database on your production server and your development machine are the same. This is very important.

2) Download and install GIT on your development box, if you are on Windows make sure to install the GIT Bash.

3) Create a free account at Github or Bitbucket, I prefer latter because you don't have to pay for private repositories

4) Match a deployment solution to the server hosting the website

GIT Downloads

GIT Basics Guide

GIT Joomla Guide - Basic

GIT Joomla Guide - Advance

  • Thanks. I think My current problem is more of code deployment than source control. I have a linode Ubuntu 14.04 server, using webmin/virtualmin to manage my websites, SSH and RealVnc available. I think the best practice for me is to make a repo out of my local html folder, then write script to hook it up with the remote www folder. But writing script is a little beyond me currently, need more reading and practicing to ask more qualified questions. Any hints are appreciated. – shenkwen Mar 22 '16 at 19:43
  • When you SSH into your server, do you have full root access? – Brian Bolli Mar 23 '16 at 1:20
  • Yes I do. I do. – shenkwen Mar 23 '16 at 1:49
  • @BrianBolli How does this work to keep the database(s)? I'm pretty new to git and not really doing much "dev" (just modding for example a purchased template and adding content) and trying to figure out a flow or if git is a good choice period. Thx. – JoelAZ Feb 22 '18 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.