Magento 2 .gitignore template for new project
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:
- Download this Magento 2 project https://github.com/magento/magento2-community-edition (if you do it via
git clone
make sure to executerm -rf .git
just after that) - Run
composer update
in the Magento root - Initialize new git repository in the root of Magento
- 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) - 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.) - 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
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:
http://www.letscodejavascript.com/v3/blog/2014/03/the_npm_debacle
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:
https://www.gitignore.io/