I'm starting to use Git to manage Joomla site builds, and I'm looking for some best practice guidance. As it stands:
- Use WHM to provision a new account. I've written a post-install hook to automatically download Joomla from Github and place it in the relevant
public_html
directory, as well as create the database and DB user - Manually install Joomla via the web interface (though currently looking for a way to automate this as well)
- Setup a bare repo above
public_html
- this is where users push and pull from. We'll call thisorigin
- Setup a standard repo in
public_html
- Add a Joomla-specific
.gitignore
- Specify the bare repo as our remote (
git remote add origin ../repo.git
) - Perform
git add .
, thengit commit -m"Initial J! Commit"
, thengit push origin master
to get the default install in our bare repo - Add a
post-receive
hook to the bare repo to automatically pull changes into the repo inpublic_html
(as the bare repo is where developers will push local changes to) - Add a
post-update
hook to the repo inpublic_html
in case anyone makes changes on the server... though they shouldn't
I'm not too worried about databases at the moment. My main issue now is dealing with Joomla file additions / changes. Obviously as I install templates and extensions certain files are going to be added and removed. Similarly Joomla updates will cause changes.
What is the best way to deal with these on-server changes? I was thinking of writing a small plugin that runs onAfterRender
or similar that uses PHPGit to perform git add .
, git commit
git push origin master
. Then, in my local copy, I can just do a pull and everything comes through. Or is there a better way?