Home
Home | Blog

iHwy Development Blog

The iHwy team shares their musings about their development experiences.

Using GIT to install OSCommerce Contributions

Posted on September 23, 2009 17:24 by Mike

Adding an oscommerce contribution to an existing site has always been a huge pain.  You have to weed through messy code and figure out where you're suppose to put in the contribution's code without breaking anything.  A lot of time the install instructions for a contribution only give you the line number to work with, and who knows if that line number is going to be accurate in your code or not.  But, today I figured out a much less painful way to do it... using git.  Now, I don't necessarily recommend doing this without first understanding git at least a little... but if you've used git before, here's what you do: 

1. figure out which version of oscommerce the site is based on (usually found part way down in includes/application_top.php; something like "define('PROJECT_VERSION', 'osCommerce 2.2-MS2');")

2. pull that code in to a git repository

3. create a branch in git for the existing site and for the oscommerce code you just pulled in (all branches are pointing at the same place at the moment)

4. checkout the new branch

5. pull down the existing site's code and copy it over everything in the git repository

6. commit changes

7. checkout the oscommerce branch

8. create a new branch for the contribution you want to install

9. check out the contribution's branch

10. install the contribution (this is now much easier since you're installing it in to the base oscommerce code)

11. commit changes

12. checkout the existing site's branch

13. tell git to merge in the contribution's branch

14. resolve any conflicts

15. commit changes

The existing site's branch should now have the contribution's code nicely merged in to it.  This works because both the existing site's branch and the contribution's branch were both based on the same base branch.  This could theoretically be used to merge in multiple contributions and / or upgrade an existing site to the latest oscommerce code base without nearly as much pain as that usually causes.  Of course there will be conflicts and you will have to manually resolve those, but with a good file merge utility, that's not nearly as bad.