Magento 2 – Version Control with Git

composergitmagento2versionversioning

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.

Best Answer

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.

Related Topic