I am starting the development of a new custom theme for Magento 2.1.x. I would like to commit on my git repository only the files related to the theme and to the custom module which I will create for this theme, not the entire Magento project.

This because at certain point a colleague of mine will install a new copy of Magento 2.1.X locally in his machine and pulling from our shared git repo.He will also contribute to the development of the theme.

The .gitignore file shipped with Magento CE 2.1.X works for the purpose I just described or do I need to add some other directories/files to the .gitignore?

Please suggest for using Git.

2 Answers 2


You don't have to add anything to file .gitignore now, because you have just start developing.

In the future, whenever you don't want the files to be included when committing, add it to the .gitignore file.

  • Ok, I was wondering if there are some files/directories which can be excluded from the begininng. e.g.: do I need to commit the setup folder for a repo which should contain only the files need for the theme and relative custom module?
    – giani.sim
    Jul 25, 2017 at 17:20
  • Yeah, You should commit the setup forlder. Because it contains the files need for the theme and your relative custom module.
    – Toan Tam
    Jul 25, 2017 at 17:50

.gitignore is used for specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; https://git-scm.com/docs/gitignore

The main purpose is ignore temporary file and configuration. Example.(etc.xml,var/cache,var/generator,var/pagecache folder) etc.

In your questions My suggestion you can maintain Magento 2.1.x separate repo. you can create clone Magento 2.1.x file in your branch and work. your can commit in your branch. Dont push in Magento 2.1.x repo. if anyone need your Theme, they will merge your branch in git.

You can follow Git comments here: https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf

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.