I installed Magento 2 using composer locally (on my local Dev environment using MAMP).

  • I added my custom theme and did all my frontend work on my local Dev site.
  • I want my code and changes to be tracked by Git and pull it in on my Staging site (from the Beanstalk remote repo)

I installed Magento 2 using Composer and @Claudiu Creanga advised me in this article to use the service Deploybot to deploy the site to Staging.

I have a few questions regarding this process:

  1. How do I have to setup my .gitignore file? In other words; which files and folders I have to track and I have to commit and push to my remote repo?
  2. How do I install my site on the Staging server? Also using Composer?
  3. Because I used Composer to install Magento 2, I can use composer update to update Magento 2 core. But how do I update my Staging site? Also using composer update? So if I understand wright I don't pull in this update changes by Git from my remote repo?
  4. How do I install and update Extensions? Also using Composer? So I don't add the Extensions via Git and I don't track the Extensions, isn't it?

1 Answer 1


You should use this .gitignore

In my opinion you should remove the line /dev/tools/grunt as you want to track the grunt folder. You deploy the composer files and a few other folders needed.

Then on your staging server you run automatic commands like:

cd ~/your_root_folder
php bin/magento cache:flush
composer install
php bin/magento setup:upgrade
grunt clean
grunt exec
grunt less
php bin/magento setup:static-content:deploy en_US en_GB

Depending on your configuration other commands may need to run.

Ideally you should install extensions with composer because it makes managing dependencies better. The truth is that few vendors offer them through composer, they still send you a zip package via email. So you should drop it in the app/code folder which is tracked by git.

*If you're using mamp, check the php version. Magento2 doesn't work with php 7.0.0 and mamp didn't yet release a newer version of php7 I think.

  • Thanks! About the .gitignore file; I added your .gitignore but it still tracking 32169 files? 1) Do I have to add /node_modules and what about /update folder? Do I have to add /update also to .gitignore file? 2) What is the purpose of tracking the grunt folder? 3) To get things clear: What are my steps to get my Staging server ready? I am a bit lost here? Do I have to do a composer install on my Staging server. What steps I have to do to migrate my local version to staging server using composer and Deploybot etc?
    – meez
    Jun 16, 2016 at 8:05
  • 1
    /node_modules should not be tracked so add it to your .gitignore. track the grunt folder because in themes.js you will add your theme settings. yes, you need to do a composer install on the staging server. composer update locally, push to staging and on staging composer installl Jun 16, 2016 at 8:36
  • 1) So I will track the whole /dev/tools/grunt folder in Git? And what about the /update folder? 2) So after I properly set my .gitignore I push all tracked code to Beanstalk remote repo. Till here I can follow the proces. But what do I have to do next? Where does Deploybot is getting involved. And before hand what do I have to do on the Staging server? 3) Can you explain this 'composer update locally, push to staging and on staging composer installl'. I don't understand exactly the proces?
    – meez
    Jun 16, 2016 at 10:59
  • sorry but do you have an answer on my last comment? Thanks!!
    – meez
    Jun 20, 2016 at 16:27
  • In addition: 1) For what do I need Composer anyway on Staging server? Is this to get the vendors once only on the Staging server? Why shouldn't I do this via ssh on the server with php composer.phar install ? 2) I need Composer on the Staging server only 1 time for the installation isn't it? The site isn't getting 100 visitors per hour and are symlinks working on shared hosting?
    – meez
    Jun 21, 2016 at 8:59

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.