Well here it is, my typical .gitignore file for every project. This doesn’t change much. Specially it is written for Yii Framework and CakePHP:
#Linux *~ *.sw[a-p] .directory #Revisioning systems /.svn/* */.svn/* /CVS/* */CVS/* .cvsignore */.cvsignore #Mac OS X .DS_Store Icon? ._* .Spotlight-V100 .Trashes #Windows Thumbs.db Desktop.ini #PHP php_errors.log #IDEs, compiled languages etc. .redcar nbproject/ *.pydevproject .project .metadata bin/** tmp/** tmp/**/* *.tmp *.bak *.swp *~.nib local.properties .classpath .settings/ .loadpath .cproject *.iml *.ipr *.iws .idea/ #CakePHP tmp/* config/database.php app/tmp/* app/config/database.php !empty #Code Igniter */config/database.php */system/logs/log-*.php */system/cache/* */system/cache/!index.html #Yii Framework protected/config/main-local.php /.htaccess
Additionally in the directories ./protected/runtime and ./assets I also added a .gitignore file containing the following:
* !.gitignore
This allows both folders to be committed into my Git repository despite them being empty. Think of it as CakePHP’s !empty. Both directories will be populated during application run time.
Thanks a lot for this post.
Can you please check if, instead of adding yet another .gitignore file here and there, can’t you simply put:
!/.protected/runtime
/.protected/runtime/*
!/.assets
/.assets/*
Like this, git will not ignore those folders and will push them to the server even if they are empty, but will, however, ignore all files inside those folders.
What do you think ?
The problem with ignoring folders and never pushing them to the server is that the directories will not be in a repo you clone from the server, and they are needed for Yii to work. I found this out today when I created a repo containing a new project skeleton and cloned it to a different machine. Yii gave me an error message asking “are you sure the webserver has write permission to the xxx directory?” when I tried browsing the new project, but the cause was because the directories didn’t even exist in the cloned project.