Duplicate and Commit

Here at Meanbee we spend a lot of time developing themes for our clients. Over time, we’ve developed a few tools to help us out along the way, today I’m going to be writing about one of them; Duplicate and Commit (DAC).

What is it?

DAC is a nifty little script which has two primary functions. To:

  1. Copy over template/layout files from a theme (usually base/default) to a theme of our choosing; keeping Magento’s intricate folder hierarchy intact.

  2. Commit this template file with either an automatically generated message or a custom one.

Duplicate and Commit Sample Usage

Cool… But why?

When we develop a theme, we only copy templates into our theme from base/default when we need to make changes. We recognise some developers like to duplicate the entirety of this folder for stability reasons. However, in our experience few have arisen and we feel this yields a cleaner theme.

With this in mind it’s a big time saver. For a typical theme, we might copy over and commit dozens of template files before making our own changes. Not only this, but good development practice dictates we automate these repetitive tasks as much as possible.

We’ve also found that committing a duplicate of the template file is beneficial since we can more easily see what changes have been made when browsing git. This is very easy to forget to do (speaking from personal experience!). Let’s see an example:

Theme Change using Duplicate and Commit

Where can I get it?

On GitHub.

Thanks for reading chaps!

Any feedback? Leave a comment below or shoot me an email