1

In my first Magento 2 project I followed an guide for installation which recommended in clone git repo to install.

Later only found this is disastrous!!! Obviously now I cannot simply use Composer to update my Magento, neither could I update it with git: the file system has been move places and when I tried to pull origin 2.1.8 I got hundreds of files listed as both added in git status which totally messed up my code.

I'm thinking installing a fresh Magento (with composer this time!), and then migrate the site over (from 2.1.0 to 2.1.8), is there an easy way to copy database so I can preserve previous history such as products, customers, orders, etc?

Why using git clone creates such problem?

1

Unless you are a contributing developer, you shouldn't clone the Magento repository.

If you are developing a store, you should create your composer project and add Magento as a dependency of your project:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name>

For complete installation details, please refer to the official documentation.

  • Yes this is what Magento recommends. However is it okay if we clone the stable releases from Git instead of using develop branch? – Rajeev K Tomy Sep 18 '17 at 7:21
  • in case you clone yes, I suggest using a specific tag – Alessandro Ronchi Sep 18 '17 at 9:07
  • Surely this is the correct way of starting a new Magento 2 project. @AlessandroRonchi you're 100% right. Magento 2 Doc is now much more comprehensive compared to 12 months ago, clearly states that cloning from git repo is not suitable for production projects. Because my git skills are so flimsy, I now decide to rebuild the whole site and hopefully I can find a way to migrate store data such as products, customers, orders, etc. – Ethan Wan Oct 8 '17 at 4:10
0

You can install Magento2 with composer and git, you see below example links:
Magento Install without Sample Data.
Magento Install with Sample Data.

0

Well, you're only changing your codebase to be pulled from another source (Git or repo.magento.com). So, in theory, you don't even have to copy your database in order for it to work.

By the way: I have never installed Magento 2 using Git, but why would a pull of a newer version mess up your code? Did you edit the core?™

  • When I started this project, around 12 months ago, I installed magento 2.1 by cloning git repo. Then 6 months later it went to production. Between then and now, the site has been moved from on server to another and somehow I lost .git file. I think it is still possible to get Magento software updated to the latest version via git (providing that I have enough git skills, but unfortunately I don't). I've edited maybe one or two Magento core files for fixing bugs and they're all listed in my developer log, so if it's not a big deal if they're over written. – Ethan Wan Oct 8 '17 at 4:17
0

I also posted this answer in Changing from a git to a composer installation

Follow these steps

1) Backup your Database and Magento Root Directory.

2) Installed A clean installation of the version of Magento 2 you are using (important) Use these links as reference to installing Magento 2 using composer:

3) Make sure clean installation is successful.

4) Delete the clean installation DB and Import backup DB

5) This step is for sites that already have content. Override some of the content of the clean installation with the content of the Magento Root Directory. Use the list below:

  • (Magento Root Directory)/app/design/frontend/(Your themes)/ (Note: only your themes, not the Magento theme unless you overrode anything)
  • (Magento Root Directory)/pub/media/ (Note: Make sure this you carefully select the right folders)

The list might change depending on your extensions and customization.

6) Make sure your site is in developer mode. https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-mode.html

7) Finally, run php bin/magento cache:flush && php bin/magento cache:clean php bin/magento setup:upgrade

This should get you moved to a composer installation Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.