Perfect Magento Workflow using Git

Magento has been gaining a lot of momentum in Australia over the last few years, and the need for us to allow developers to collaborate on projects whether they be in Perth, Melbourne or Sydney has pushed us to address a problem many web developers face with every framework they use: workflow. My main goal was to allow multiple developers to work on their own versioned copy of a project and be able to deploy Magento to multiple sites (live, staging, dev) with one click. Here's what I came up with. You'll need:

  • Magento
  • Advanced Developer Tools (ADT) for Magento
  • Git
  • acount (GitHub, Beanstalk, etc would work too)

Note: To follow and understand this post, you'll need some experience or understanding of Git and Magento.

Setup repo on Springloops

  • Create project
  • Install your SSH key (copy the contents of ~/.ssh/
  • Create deployment servers (live and staging, and dev if needed)

Setup GIT repo

git init git config --global "My name" git config --global "" (This must be the same email as your Springloops account) touch .gitignore echo "var/*" >> .gitignore echo "media/*" >> .gitignore git add .gitignore git commit -m "Added gitignore" git status git add . git commit -m "Added existing code base" git remote add origin REMOTE_REPO_URL_STRING git push -u origin master git checkout -b staging git push -u origin staging git checkout -b dev git push -u origin dev


The first time you push to live, you'll have to install the DB manually (use a sql dump of your staging site and change base_urls). From then on, DO NEVER MAKE CHANGES TO YOUR LIVE DB manually! Make all your DB changes in Magento install & upgrade scripts! (See further along) This means that all your DB changes will automatically deployed! To allow to have multiple DB environments and still have app/etc/local.xml under source control, you'll need Magento ADT. Then configure your local.xml accordingly (see below)

Multiple database environments

Thanks to our Magento ADT extension (July 2011 release), you can have different DB connections in your local.xml and have them kick-in depending on the hostname you're using. That allows to have the details for live, staging, dev and multiple local devs in one file and under source control. That also means that you can deploy and be sure that the correct DB will be used. ... 1mystagingurl.commysql4SET NAMES utf8pdo_mysql1mydevurl.commysql4SET NAMES utf8pdo_mysql1 ... So, "default_setup" are your live/default details. Then, add an "extras_setup" section. In there, you can add as many sections as you want (and name them what you want, eg "staging_setup"). You must add a "domain" tag to each to tell when to kick-in.

Magento install & upgrade scripts

To never have to remeber what changes you made through the back-end during development, simply NEVER DO IT! Use install/upgrade scripts instead.

The links



Config changes: Mage::getModel('core/config_data') ->load(57) ->setValue('blank') ->save(); Mage::getModel('core/config_data') ->setScope('stores') ->setScopeId(1) ->setPath('design/theme/default') ->setValue('shopfortots') ->save(); Design updates (delete) $design = Mage::getModel('core/design'); $design->load(1); $design->delete(); CMS Page: Mage::getModel('cms/page') ->load('home') ->setContent($content) ->setStores(array(1)) ->save(); CMS Block: Mage::getModel('cms/block') ->load('footer_links') ->setContent($content) ->setStores(array(1)) ->save();


Just leave us a comment, and don't forget to follow us on GitHub:


Hey Jonathan,

thank you and DogHouse for providing this nice extension.

But where can I find the July 2011 release of the Advanced Developer Tools? I took a look at github, but all sources are from May 15, 2011. I would like to make use of the domain dependent database connections.

Thanks in advance for your feedback.

Best regards from Berlin,


Hi Thilo,

We're just running a bit late with the July release. You should see it up on MagentoConnect by the end of the week.

Also, if you change branches on Github, you'll notice the last push was to branch "panels" on the 20th of June! :)

Kind regards

I can`t find the instructions about how to enable and use this extension, it is already installed but the page on magento forums is giving me an error. I need multiple local.xml files, and live CSS editing.

Hi Lennon,

There are some issues with the extension with Magento 1.6+. I'm hoping to address this asap, but it might be a few weeks befroe I can get to it.

The extension doesn't give you multiple local.xml files but allows you to put different configurations in the main local.xml file.

See this pastebin for the format (copied from above):

You might also need to clear your cache and restart PHP in some cases.


Add new comment

Filtered HTML

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockcode>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.