Search code examples
phpgitgithubgitignore

Git submodule .gitignore still tracks file


My problem is very simple.

I have project, this project includes as a submodule another project. This submodule has a .gitignore as follows:

*~
~*
.DS_Store
nbproject
core.ini.php

Yet, every time I create a new core.ini.php file (for local specification purposes), the file gets included in the watched file list, committing it into the repository. So despite the .gitignore of both the project AS WELL as the submodule specifying to ignore that file, it still gets added.

Here is just a screenshot to show that it is indeed added:

.gitignore addition

I would appreciate any advise or help. Thank you.


Solution

  • To expand on my comment on the OP, it looks like you probably added that file to the index at some point prior to adding it to the .gitignore file.

    It's fairly easy to get yourself into this tight spot where git won't track the delete of the file (because it's already in the .gitignore!) - so the easiest way to achieve what you need is to:

    1. Remove the specific file from the .gitignore file
    2. Delete the file
    3. Commit this deletion action
    4. Add the line back into the .gitignore
    5. Re-add your ignored file.