Joomla Git Management


We're starting to use Git to manage our Joomla installations. There's quite a bit of setup involved in bringing a Joomla installation under Git control, and managing the git repository. Here are our notes:

Update a Joomla installation


With a Joomla install already set up in git, simply git pull the new changes over, and check the README-FREELOCK for any manual changes necessary.

Next steps: Create a script to automate git updates

Convert a Joomla installation to use git


This is the painful part. The overall strategy is to create a new clone of the Joomla git repository, move it to the installation, reset it to use the current files, and add any custom files to the repository.

Before starting, log into the admin area of the site and check the released version. Also check to be sure there are no database upgrades to do between this release and the current release, and back up all the files.


cd /var/www/html
git clone git://git.freelock.com/git/joomla.git
cd joomla
git checkout -b main origin/freelock15installed # branch with installation dir removed
cd ..
mv joomla/.git seattlethistles.org
rm -Rf joomla
cd seattlethistles.org
git reset --hard # this replaces any tracked files with the current version
git add configuration.php templates # add any files not tracked (use git status to find)
git commit

Notes:

Create a new Joomla installation from git


This one is easy:
cd /var/www/html
git clone git://git.freelock.com/git/joomla.git newsite.com
cd newsite.com
git checkout freelock15 # branch that contains checked out code
... run through installer
git checkout -b main freelock15installed # removes installer directory
git add configuration.php
git commit

Install a new component/module in the base Freelock git branch


The main thing to do is get the database creation script updated as appropriate.

We add the JCE editor to all of our installations. (Not yet done in git).

All maintenance is done on a local working copy of Joomla, and pushed to our central repo.

git checkout freelock15  # branch with installer
... unpack components/modules/plugins/whatever
... move directories to appropriate place in the tree, git add
... edit installation/sql/mysql/joomla*, adding any new table definitions and rows
... in components/modules/plugins table as defined in the add-on xml file
git add installation
git commit
git push
git checkout freelock15installed
git merge freelock15
git rm -r installation
... resolve any other conflicts
git commit
git push

Set up local working copy

Here's how to create a local working repository for git:
(Rough notes, from memory)
git clone servername.com:/var/cache/git/joomla.git # use SSH path, since we need to push
cd joomla
git checkout -b freelock15 freelock15
git checkout -b freelock15installed freelock15installed
... edit .git/config to add "push" section to origin, and branch sections for pushing

Update the Freelock git branches for a new release


The main challenge we have with Joomla is that there are lots of files with mixed line endings in the Joomla repository. So we essentially need to clean up each checkout before merging it, to avoid unnecessary merge conflicts (which end up in nearly every file if we don't do this).

Here's how I'm addressing it:


git clone your_server:/path/to/joomla.git #make a temporary copy of your joomla git repository
git config core.autocrlf true # temporarily set git to convert lf -- crlf
git checkout -b tmp svn/1.5.x # makes all files crlf
rm -Rf 1.5.{[0-9],10,11} # remove all releases older than version 1.5.12 from wc
rm -Rf 1.5.*RC* # remove Release candidates from wc
mv 1.5.12/* . # move contents of current release to root of wc
rm -Rf 1.5.12
git commit -a # converts to lf on commit, only inside repo, not in working tree
git config core.autocrlf false # turn back off

git checkout --track -b freelock15 origin/freelock15
git checkout tmp -- * # this pulls all files (other than hidden) into current tree, without merging
git commit -a -m 'merged svn/1.5.12'
git branch -D tmp
git push #push updates back to repository

Now we should have a much cleaner delta to pull over to other branches:

 git checkout --track -b freelock15installed origin/freelock15installed
git merge freelock15
git rm -r installation # if this fails with a conflict
git commit # if merge was not clean
git push #push updates back to repository