0

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:

/pub/media/amasty/
/pub/media/amlabel/
/pub/media/back/
/pub/media/cache/
/pub/media/css_secure/
/pub/media/custom_options/
/pub/media/email/
/pub/media/gbu0/
/pub/media/images/
/pub/media/js/
/pub/media/khxc/
/pub/media/klevu_images/
/pub/media/mbimages/
/pub/media/meigee/
/pub/media/og_image/
/pub/media/xmlconnect/

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

0

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

Only add which requirements by theme or Magento editor related.

/pub/media/*.*
!/pub/media/.htaccess
/pub/media/attribute/*
!/pub/media/attribute/.htaccess
/pub/media/analytics/*
/pub/media/catalog/*
!/pub/media/catalog/.htaccess
/pub/media/customer/*
!/pub/media/customer/.htaccess
/pub/media/downloadable/*
!/pub/media/downloadable/.htaccess
!/pub/media/favicon/*
/pub/media/import/*
!/pub/media/import/.htaccess
/pub/media/logo/*
/pub/media/custom_options/*
!/pub/media/custom_options/.htaccess
!/pub/media/theme/*
/pub/media/theme_customization/*
!/pub/media/theme_customization/.htaccess
!/pub/media/wysiwyg/*
!/pub/media/wysiwyg/.htaccess
/pub/media/tmp/*
!/pub/media/tmp/.htaccess
/pub/media/captcha/*

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.