Question

I have my cakephp project deployed in a shared hosting, but it's unversioned. I would like to version it using git or mercurial, and deploy changes easily. What steps do I have to take? Should I install git first in my shared hosting first and make a clone in my local environment? Should I have a separate folder with repos in my shared hosting and then deploy changes with some utility?

thanks

Was it helpful?

Solution

  1. The subversion server should be different from the production server. You can create an account on github and host it there as a private project.

  2. On the production server, you will just pull the latest changes when you want to make an update (or use a continuous integration server - jenkins, teamcity, bamboo etc)

  3. On your local, you will push/pull changes to the same subversion server.

OTHER TIPS

Many shared hosting sites don't allow you to have shell access on their server, and some don't have git installed. If you depend on pulling changes directly to the production server, then when you're asked to install on a server that doesn't support shell/git, you have to do something different... which is painful.

Here's a solution that works for me:

  • Read up on git-flow
  • Have a project folder that directly mirrors your development files. This is in the develop branch.
  • Have a project folder that directly mirrors your production files. This is the master branch.

When you are happy with your development site, commit and push your changes. Then change your project (in your IDE) to the production version. Pull and merge your changes (but don't commit just yet). My IDE then allows me to upload just the changed files, which I then commit.

I realise that this isn't the solution that many people adopt, and as cornelb said, a continuous integration server would probably streamline this process a bit. But it works very well for me, and only requires FTP access to the shared server where you are deploying your code.

Are you able to install Git in your shared hosting? In most cases they won't allow it.

If yes, you can use post-receive hook to checkout the files the the directory your project is:

GIT_WORK_TREE=/var/www/example.org git checkout -f

Or you can use one of these tools that do deployments over FTP form your local git repo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top