I've installed magento2 via composer. I couldn't find any information about common gitignore files for magento2 and the the file structure is still strange to me.

Can someone share a common gitignore template? Thanks!


Assuming that project was created using

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .

take this .gitignore and put into your project root. It also makes sense to add /update and /phpserver to ignore list.

Another option:

  1. Download this Magento 2 project https://github.com/magento/magento2-community-edition (if you do it via git clone make sure to execute rm -rf .git just after that)
  2. Run composer update in the Magento root
  3. Initialize new git repository in the root of Magento
  4. Almost all core files/directories are already added to the root .gitignore, but it is better to add the following 2 as well /update and /phpserver (just add these 2 lines to .gitignore)
  5. Add all untracked files to git and commit them (should be only 3 files, all other are already added to .gitignore in the root of Magento.)
  6. Start development of your modules as usual (put them under app/code/YourCompanyName/YourModuleName), now you will have only your custom code in your git repository
  • thanks, but when I installed magento2 via composer there was no gitignore file in the root – Claudiu Creanga Nov 20 '15 at 15:12
  • have you used composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name> ? – Alex Paliarush Nov 20 '15 at 15:13
  • yes: composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition . – Claudiu Creanga Nov 20 '15 at 15:14
  • 1
    Yes, should be good. Updated response. Probably this project is not intended for developers developers, which is strange. Will try to find out. – Alex Paliarush Nov 20 '15 at 15:21
  • 1
    vendor/magento/magento2-base/.gitignore does not ignore core files, unlike this one github.com/magento/magento2-community-edition/blob/master/… . I suppose it will be added automatically in scope of future releases of M2 – Alex Paliarush Dec 4 '15 at 11:36

Your .gitignore should depend on your deployment process. If you use composer install in production then it makes sense to have the vendor folder ignored, but it is very risky:


If you don't have some other strategies for deployments I would commit the vendor folder and not run composer in production.

Also I removed grunt folder from gitignore, imo it should be tracked because you have changes to themes.js file etc.


I normally use the following website to generate my gitignore:


  • probably better as a comment but one of the best resources I've found from here so thank you! :) – treyBake Feb 26 '18 at 13:35

For my magneto2 projects I had used git ignore from.


  • 1
    link is broken can you copy / paste here please – Alex B Oct 22 '20 at 12:04

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.