0

So I have a CakePHP app, and I have several environments. I just want the gitignore to work so I don't have to reset the database.php and core.php every time I push from one to the other.

This is my .gitignore:

# User specific & automatically generated files #
#################################################
/app/tmp
/app/Config/core.php
/app/Config/database.php
/app/webroot/img/users/
/lib/Cake/Console/Templates/skel/tmp/
/plugins
/vendors
/node_modules
/build
/dist
/tags
*.mo

# IDE and editor specific files #
#################################
/nbproject
.idea

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

But doing this: Ignore files that have already been committed to a Git repository

Actually deletes all the files from the repo!

How can I make it so that I am just not regarding these files in any of my environment so they don't get carried over from one to the other?

Community
  • 1
  • 1
itamar
  • 3,837
  • 5
  • 35
  • 60
  • Almost nothing deletes anything from the *repo* (files inside the `.git` directory), so I assume you mean "work-tree" where you say "repo". Note that `git rm --cached` will remove paths from the index without removing them from the work-tree. This does, however, cause problems if you ever check out older commits that have the files you don't want them to have: git will attempt to create the files and if it succeeds, on switching back to a later version that lacks them, it will remove them at that point (because it must: that's the change from old to new: remove those files!). – torek Apr 09 '15 at 02:17
  • @torek - okay my worry was because following the article I linked to above, I did `git status` before committing and saw `deleted, deleted, deleted` all over - that shouldn't concern me because it's just the work tree and not the actual filesystem? – itamar Apr 09 '15 at 02:23
  • 2
    I think your best solution is to have environment-level configuration setup. I had the same issue as you, and instead of fighting a losing battle with git, I setup my app to detect environments and apply settings/configurations easily. You will be able to control debugging, database connections and whatever else that is configurable in CakePHP. You can do it easily or use a plugin like this one https://github.com/josegonzalez/cakephp-environments – AKKAweb Apr 09 '15 at 03:47
  • 1
    Your terminology doesn't match git's (nor mine), but `git status` will indeed show things as "deleted" as the change (diff) between "current revision" and "what will be committed if you commit now" is "remove these files from the checked-in version". If they exist in the work tree, git will say they're "untracked" unless they're also added to `.gitignore` (which means something closer to "git, please don't tell me that these files are untracked" rather than "git, please ignore these files"). – torek Apr 09 '15 at 03:49
  • @AndreSantiago - I actually tried that plugin but got stuck because I couldn't figure out how to set the different database configs. – itamar Apr 09 '15 at 04:31

0 Answers0