4

What is the best way to version control Magento 2 store on Git?

How should I set up the repo/s to be flexible and reliable in a long run?

I use composer to install all third party modules (when that’s possible) so should I just VC the composer.lock file and then VC the app directory with all custom modules and theme?

Should I have one repository containing the whole store as it stands?

Or should I version control every single module on its own repository?

Any suggestions? I want to set that up right from the beginning.

2 Answers 2

1

As @vmp suggested, version controlling each module as individual repository does not make sense, because when you would want to rollback, you will find yourself in trouble.

Version controlling whole Magento also does not make sense, because apart from app directory and pub/media, nothing is so important to keep in the git repo.

Reason: vendor folder basically consists of the code which Magento provides you. So you can anytime get the latest version of it from Magento.

Apart from that, pub/static, var etc. directories keep only temporary data, so there is no need to keep it in the git repo.

You can put all these stuff in the .gitignore file.

There is a great blog post you can visit to read more about version controlling the Magento 2 website.

2
  • sooooo, you are suggesting to version control app directory only and use composer to VC the vendor? I thought this might be the right approach but wanted to hear what people think.
    – Greg
    Commented Jun 21, 2018 at 10:33
  • Yes, you can also keep folders under pub/media directory in the repo. Commented Jun 21, 2018 at 10:57
0

Why would you version control every single module?

this sounds like an easy way to lose track of things and have a crazy amount of repositories.

I would suggest backing up either the entire Magento installation so you can easily roll back or doing as you suggested and just do the app folder and your composer.lock file and then running composer install when you roll back.

You should also consider backing up your media, such as images on the website and other folders which may have custom content

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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