'Ignore wp-config.php WordPress not working

I have tried a lot to gitignore wp-config.php on a fresh installation of WordPress, not fresh installation also but none of them has worked. I am using PhpStorm.

Does anyone have an idea?

Please note that I have used rm -- cached and all know solutions.

the commands tested

git rm --cached wp-config.php

add file to .gitignore


Solution 1:[1]

I suggest that wp-config.php is already in the repository!? You have to remove them with:

  1. Add to your .gitignore file wp-config.php
  2. Remove from repository with: git rm --cached .
  3. Then git add . and commit with git commit -m "add wpConfigPhp to gitignore"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maik Lowrey