I've inherited a Magento 2 codebase and the .gitignore file matches the one in the Magento 2.3 repo.

I downloaded the latest copy of the database and the /pub/media folder from the live site for my local dev environment so I could get as close a match as possible.

However, I now have a lot of directories in /pub/media that Git is picking up as untracked files. I feel like I should be gitignore-ing these directories as they aren't currently in the codebase, but I don't want to do anything that will upset the live site on deployment.

These are the directories being picked up by Git:


It looks like most of these have been created by/for the theme that has been used.

Should I add these to the gitignore?

1 Answer 1


Formally, most of the Magento projects does not include media in their code base .

Only add which requirements by theme or Magento editor related.


Above is an example Magento standard list for gitignore.

As per your list /pub/media/cache/ and /pub/media/css_secure/ and /pub/media/js/ must be addedin ignore.

Other any folder which is related to cache, should be added to ignore the list

Suppose , /pub/media/amasty/ folder has a cache folder /pub/media/amasty/cache, then i suggest that you should add /pub/media/amasty/cache at ignore list.

Simple word,call is yours which folder you want to add at ignore list.

Should add static files(Noncodes files) folders/files to ignore list.

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.