Search code examples
gitmagentogit-submodulesgit-subtree

Best practices for using Git with Magento?


I'm working at figuring out how to best work within my own repo for custom code while integrating with a vendor's library (in this case Magento). In my case, I will not need to push up patches to the vendor (although that would be a great side benefit).

I've looked into git submodule and git subtree. I don't think git submodule will work for what I need. Magento has the following type of tree structure:

/app
  /code
     /community *
     /core
     /local *
  /design
     /adminhtml
     /frontend
        /base
        /yourtheme *
/lib
  /Zend
  /Varien
  /yourlib *
/js
  /yourjs *
  /varien
  /mage

Using git submodule seems to work best in separate folders (e.g. / is your app and /vendor/magento is the submodule). However, with this degree of intertwining, a submodule doesn't seem like a good solution. Am I wrong about this?

That leaves me with git subtree. But with git subtree, the same core assumption (that the vendor branch is, as implied by the name, a subtree) doesn't hold true. Magento isn't a subtree, but the core library that my project fits within. Is that correct?

If those two methods of git don't work, are there other ones I should know about that would do what I'm trying to accomplish?

The final option I'm reluctant to pursue is having a repo that I then just apply over the latest vendor changes (pulled in from a tarball). I'm reluctant to pursue this as I feel that having the vendor's log information (pulled from https://github.com/magentomirror/magento-mirror) would be greatly helpful in sorting through new updates and figuring out what changes have affected me.


Solution

  • I think you can use modgit tool for this: https://github.com/jreinke/modgit You'll be able to clone some Magento modules with modgit clone command. A full example is available here: http://www.bubblecode.net/en/2012/02/06/install-magento-modules-with-modgit/