0

I have a CodeIgniter php project in repo and have done a lot of updating to the database config file which contains all of my login information. I want other users or developers to be able to checkout my project and still get the config file, just without my login.

I'm sure this is a simple oversight somewhere, but I cannot find a reference to it at all.

Pilipo
  • 97
  • 1
  • 7
  • 1
    possible duplicate of [Protect files from svn commit](http://stackoverflow.com/questions/2779293/protect-files-from-svn-commit) – Greg Hewgill May 02 '12 at 22:55
  • No, this is slightly different problem. – MrTJ May 03 '12 at 13:06
  • Greg, that is pretty close to the solution I have been using, but I am hung up on how others are keeping a vanilla config.php without using this template method. Code Igniter is a specific example with their use of the ./application/config/database.php file. I understand that every version control solution has an inconvenience (as mentioned in your link) but surely a cleaner method for handling this exists. Thanks for the link. – Pilipo May 03 '12 at 15:55

1 Answers1

1

No, you can't do that: svn is a file based version control system. This means that it handles each file as a unique, atomic entity, that can have separate history, be committed or ignored, but only as a whole file.

If you want to hide your credentials you will have to extract the sensitive information from your config file (say config.php) to another file (say credentials.php). Then include credentials.php in your config.php and add credentials.php the svn ignore list without committing it. You will also have to communicate your colleges to put their credentials in their credentials.php, or even better you can commit a template credentials.php as described in Greg's link.

Community
  • 1
  • 1
MrTJ
  • 13,064
  • 4
  • 41
  • 63
  • I was afraid of that. This may be filed under RTFM, but how do repo's such as Wordpress and CodeIgniter handle the day to day management of keeping the commits vanilla for future users? – Pilipo May 03 '12 at 15:47
  • Sorry I don't understand quite well; what do you mean "keeping the commits vanilla for future users"? – MrTJ May 04 '12 at 07:43
  • Sorry, I meant having the contents of config.php consist of statements like $server_name = ''; instead of statements like $server_name = 'http://www.philliplehner.com' – Pilipo May 04 '12 at 21:40
  • 1
    I have found functionality in tortoiseSVN in Windows that allows me to point to pre- & post-commit hooks that will trigger a script of my choosing. So taking your advice, I name my local secret data "config.php" (so that servers connect properly) and my default, clean data "_config.php". Both hooks point to a script that swaps the _config with config. That way I never accidentally post my login information to the open source community. Downside is that my project always looks like I need to commit changes, but I can live with that. – Pilipo May 04 '12 at 21:47
  • If you need to have the empty `$server_name = '';` declarations in the `config.php`, then this is the best approach. – MrTJ May 07 '12 at 14:36