What do you put in your .gitignore for ExpressionEngine sites?

11

3

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?

Richard Frank

Posted 2012-11-27T21:39:50.170

Reputation: 1 021

Answers

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.

Ryan Masuga

Posted 2012-11-27T21:39:50.170

Reputation: 1 317

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/*

UltraBob

Posted 2012-11-27T21:39:50.170

Reputation: 808

1Doesn't this mean the avatars directory won't be created at all when you clone the repo? – Richard Frank – 2012-11-28T05:11:57.023

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 – 2012-11-28T13:43:55.623

1Richard, see my answer here that will still allow you to preserve the ExpressionEngine images directory structure, without versioning the files in them. – Ryan Masuga – 2012-11-28T14:31:54.373

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.

Tyssen

Posted 2012-11-27T21:39:50.170

Reputation: 1 879

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/

Paulo Elias

Posted 2012-11-27T21:39:50.170

Reputation: 1 177

1Just 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 – 2013-04-02T21:26:15.873

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

Adam Christianson

Posted 2012-11-27T21:39:50.170

Reputation: 592