11

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?

18

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):

/assets/images/captchas/*
!/assets/images/captchas/index.html

/assets/images/member_photos/*
!/assets/images/member_photos/index.html

# 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.

| improve this answer | |
5

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

.DS_Store

# Images
images/avatars/
images/captchas/
images/smileys/
images/member_photos/
images/signature_attachments/
images/pm_attachments/

# Caches
sized/
thumbs/
_thumbs/
*/expressionengine/cache/*
| improve this answer | |
  • 1
    Doesn't this mean the avatars directory won't be created at all when you clone the repo? – Richard Frank Nov 28 '12 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 Nov 28 '12 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. – Ryan Masuga Nov 28 '12 at 14:31
4
*.DS_Store
.gitignore
.htaccess
.ftpquota

/expressionengine/cache/*
/assets/cache/*
/uploads/avatars/*
/uploads/member_photos/*
/uploads/pm_attachments/*
/uploads/signature_attachments/*

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

| improve this answer | |
3

Your paths may vary:

# Global Files
!.gitignore
.htaccess
.sass-cache
# .svn
.DS_Store
config.local.php
config.dev.php
[Tt]humbs.db

# Images
src/www/public_html/assets/ee_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/


# UGC
src/www/public_html/assets/uploads/*

# Caches
sized/
thumbs/
_thumbs/
cache/
| improve this answer | |
  • 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 Apr 2 '13 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. – Rick Lecoat Jan 18 '19 at 12:40
2

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
*
!*/
!*.php
!*.css
!*.xml
!*.htaccess
!*.sql
!*.js
!*.shtml
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.