Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Git with your CakePHP Project

I use git as my primary version control system, and have recently started using git on my CakePHP projects. This is my current .gitignore file:

app/tmp
vendors/

As used in the cakephp git repo, but this causes a bit more work for me when deploying the project to a server, because I have to go in and create all the app/tmp/ sub-directories by hand before they will work correctly. Is there a way to set it up to ignore the contents on these folders, but to still have them under git control so they appear when I clone the repo into the hoted directory?

I also have been having an issue with my git index being reset while I am working on it, which is causing me to have to do a lot more commits than should be necessary, any ideas on that also?

like image 566
trobrock Avatar asked Feb 07 '10 19:02

trobrock


2 Answers

Git stores only files, not directories, so you can for example add a hidden file into that directory and commit it.

  1. Remove app/tmp/ from .gitignore
  2. touch app/tmp/.keep
  3. git add app/tmp/.keep
  4. git commit
  5. Add app/tmp/ to .gitignore
like image 112
Esko Luontola Avatar answered Oct 05 '22 03:10

Esko Luontola


As mentioned git only stores files, not directories. By default cake's .gitignore file ignores all contents in the tmp folder to prevent tmp files being added to your repository.

You can (and should) however do this after you create a project:

cd /my/app
git add -f tmp

which will do this:

$ git status
# On branch master
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#   new file:   tmp/cache/models/empty
#   new file:   tmp/cache/persistent/empty
#   new file:   tmp/cache/views/empty
#   new file:   tmp/logs/empty
#   new file:   tmp/sessions/empty
#   new file:   tmp/tests/empty

As such your tmp folder structure is ready to be committed, but all other files in your tmp dir will (continue to) be ignored.

like image 33
AD7six Avatar answered Oct 05 '22 02:10

AD7six