1

I am working on a laravel project and we have separate settings for database.php in local and on server and I want to ignore this file but when I am adding this line in gitignore database.php still shows in git status

/config/database.php

I also tried

config/database.php

but does not work so any assistance will be appreciated.

Dhaval Chheda
  • 4,637
  • 5
  • 24
  • 44
  • Note that `.gitignore` doesn’t affect already tracked files. – Biffen Mar 09 '18 at 07:57
  • Possible duplicate of [Ignore files that have already been committed to a Git repository](https://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository) – phd Mar 09 '18 at 12:33

1 Answers1

3

You don't want to ignore the config files, rather have separate .env files for development and production. Read the values from the .env files into your config like:

'db_password' => env('DB_PASSWORD'),

Set the value for DB_PASSWORD in the .env files like:

DB_PASSWORD=12345
  • The issue is that file comes up again and again for git status and if i do not commit it then changes get reverted and I have to add my changes again.. that is a pain point – Dhaval Chheda Mar 09 '18 at 09:23