1

I have some basic git questions, which i do not understand yet I hope someone can help me. Lets say I'm working on a Magento project, I run it local but i want to bring it online. So i push my shop to my server using git. Everything works fine until Magento provides an update. So here is my question:

I make any changes in my local directory and git add + git commit them, but when i update my Magento Shop through Magento Connect from 1.7 to 1.7.1 I will have a different setup on my server then I have on my local computer, right?

So what do I have to do, do make them equal? Do I have to make a checkout from the version runed on my server and replace it with my local magento?

Kevin Katzke
  • 3,581
  • 3
  • 38
  • 47

2 Answers2

1

From a version control point of view you do not want to have your development environment and live environment on the same branch. For example you could use the master branch for your development and then have your live environment on a stable branch. There are also branch structures with multiple feature, release and hotfix branches. But lets keep it simple for now.

Regarding updates. You never want to run them on a live environment directly. It's nearly impossible to do a rollback of the related DB changes. So always update and push your work upstream from dev to live instead of the other way around.

So always do upgrades on your dev environment (thus master branch), and after testing commit them to your repository. Afterwards you can either merge or cherry-pick to the other branch. Afterwards update the live branch (i.e git pull or git fetch, git rebase) to deploy the upgrade.

Tim Hofman
  • 1,068
  • 7
  • 10
  • Hey, thank you for your answer. So i did a mistake updating my Magento Shop to 1.7.0.1 through Magento connect yesterday :/ Just to clarify: Instead of updating my shop online i would have to downloading the update, than updating my local shop and after testing it, pushing to my live environment? What ist the common way to develop PHP project and having a local and live environment, is it good practice to store my local environment in my htdocs folder, to have the ability for testing purposes on my local server? Then to run git init it this folder and pushing my project live? Thanks! – Kevin Katzke Aug 14 '12 at 18:43
  • Last question: How can i fix my mistake of updating my shop live? – Kevin Katzke Aug 14 '12 at 18:44
  • You always want your local codebase to be a clone (git clone) of a branch. So in this case probably 'master'. Then after changed you can push them to the repository. Afterwards you locally switch to the other branch 'stable' and either merge or cherry-pick your new commits to that branch. Then again push your work to the repository. After this you can retrieve the updates on your live environment; which should be a git clone of the stable branch. – Tim Hofman Aug 14 '12 at 18:49
  • Regarding your 'mistake'. If you were not running version control at that moment it's going to be nearly impossible to revert this change. You probably just might want to upload (but rather git clone) a new codebase to that environment. Also you have to figure out what DB changes were made and manually revert them back, or if possible just install a new DB, but that will probably be impossible see you will probably have live data already in there. – Tim Hofman Aug 14 '12 at 18:51
  • The update to 1.7.0.1 went good, everything is working fine. Isn't it possible, to git pull my live environment and replace it with my local one? Afterwards i create a branch of my local master called "dev" for future development purposes. From this moment on i will maintain a common environment in wich i separate my "dev" and my "stable" codebase. Would that work good for me? – Kevin Katzke Aug 14 '12 at 22:00
  • Ok, well the quickest way is then to just transfer those files to you local machine. Then your codebases are identical. From there you can create your branches. – Tim Hofman Aug 15 '12 at 06:40
0

I (am attempting to) use this workflow with my Magento installation and upgrade. IMHO, there is no way to seamlessly upgrade a Magento live site. At some point, downtime is needed to stop orders coming in while the DB rebuilds to the newer version.

The closest I get is to set up another cloud instance with the new version running and nuke the database once all the bugs are worked out. Then import the current live DB and let the new magento host churn on that for a while.

Then decide whether to disable your old site requiring manual data entry once the upgrade is finished.

Then once new Magento host is working, switch the domain to point to the new instance.

Krista K
  • 21,503
  • 3
  • 31
  • 43