Using Git with your CakePHP Project

I use git as my main version control system and recently started using git in my CakePHP projects. This is my current .gitignore file:

app/tmp vendors/ 

As used in cakephp git repository, but for me it works a little more when deploying the project on the server, because I need to log in and create all the applications / tmp / subdirectories manually, they will work correctly. Is there a way to set it to ignore the contents in these folders, but still have them under git control so that they appear when I cloned the repo into a hot directory?

I also had the problem that my git index was reset while I was working on it, which forces me to make a lot more commits than necessary, any ideas on this too?

+6
git version-control php cakephp
source share
3 answers

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

  • Remove app / tmp / from .gitignore
  • touch app / tmp / .keep
  • Git add application /tmp/.keep
  • Git commit
  • Add application / tmp / to .gitignore
+11
source share

As already mentioned, git stores files, not directories. By default, the cake .gitignore file ignores all contents in the tmp folder so that tmp files are not added to your repository.

You can (and should) do this after creating the 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 

Thus, your tmp folder structure is ready to commit, but all other files in your tmp disk will be (ignored) ignored.

+4
source share

My .gitignore file.

 tmp/* [Cc]onfig/core.php [Cc]onfig/database.php webroot/files/ webroot/img/photos/ !empty .DS_Store 

If you notice that I have an empty space that saves me from creating .keep files, all of which are so SVN back. Finally, you will also see that I use this configuration for cakePHP 1.x and 2.x projects marked with [Cc]. I have some settings for folders where user files are stored, so I always ignore them. Finally, .DS_Store ignores my MAC files created for my project.

+1
source share

All Articles