I'd like to keep my git repo as clean as possible without cache files and content image files. Also I'd like to preserve the ExpressionEngine images directory structure. What are you gitignore directives to achieve this?

5 Answers 5


If you want the directories to still get created, you need to have something in them, so I make sure there is an index.html file in each of the EE image directories that says "Directory Access not allowed" (or similar). Then, for each of the directories you can add rules like the following (your paths may vary):



# and so on...

That will ignore all the items in those directories except the index.html, so when you clone the site, at least the directory structure will be preserved, but none of the images will come with.


The github/gitignore repo is usually a good starting place for gitignore defaults, and I think it is in this case as well:


# Images

# Caches
  • 1
    Doesn't this mean the avatars directory won't be created at all when you clone the repo? Commented Nov 28, 2012 at 5:11
  • Yeah, I guess it does. Never bothered me because I never have my images folder there anyway. It may be worth changing that and submitting a pull-request.
    – UltraBob
    Commented Nov 28, 2012 at 13:43
  • 1
    Richard, see my answer here that will still allow you to preserve the ExpressionEngine images directory structure, without versioning the files in them. Commented Nov 28, 2012 at 14:31


The path to some of your folders will obviously be different.


Your paths may vary:

# Global Files
# .svn

# Images
# src/www/public_html/assets/ee_images/avatars/
# src/www/public_html/assets/ee_images/captchas/
# src/www/public_html/assets/ee_images/smileys/
# src/www/public_html/assets/ee_images/member_photos/
# src/www/public_html/assets/ee_images/signature_attachments/
# src/www/public_html/assets/ee_images/pm_attachments/


# Caches
  • 1
    Just a note on how git ignore works... cache/ (note the trailing slash) matches the cache directory presumably anywhere, however, cache/* matches files in only the cache directory relative to the .gitignore file. In other words if you're trying to follow Ryan Masuga's method above then for subdirectories you will have to write out their paths explicitly, e.g. instead of cache/* !cache/index.html you'd have to put system/expressionengine/cache/* !system/expressionengine/cache/index.html.
    – notacouch
    Commented Apr 2, 2013 at 21:26
  • To avoid having to specify the whole path from the .gitignore file, you could use the double-asterisk wildcard, e.g.. **/cache/* **/cache/index.html. This would have the effect of leaving you with a cache folder containing just an index.html file, as in notacouch's example above, but it will do that for any folder named cache… which may not be what you intended. So maybe cache isn't the best example for this. A better example might be **/member_photos/* **/member_photos/index.html because there are unlikely to be multiple 'member_photos' folders.
    – RickL
    Commented Jan 18, 2019 at 12:40

Lately I have been using this as the default gitignore for non-EE projects and I was thinking of adapting it for EE. i'm open for suggestions.

#ignore everything apart from php, css, xml, htaccess, sql, js

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.