Reputation: 11295
In .gitignore I have
phpmyadmin
.idea
config.php
admin/config.php
system/cache/*
system/logs/*
image/cache/*
git is somehow ignoring config.php
file in system/library/config.php
why that can happen ? and how to avoid that ?
Upvotes: 1
Views: 94
Reputation: 1328522
You can try and exclude the file from the gitignore rules at that path:
config.php
!system/library/config.php
See more at gitignore
:
[The] prefix "
!
" negates the pattern; any matching file excluded by a previous pattern will become included again.
It is not possible to re-include a file if a parent directory of that file is excluded
Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.
Nguyễn Thái Ngọc Duy (pclouds
) is trying to add this feature:
Upvotes: 1
Reputation: 333196
If you include a filename (or glob) that doesn't contain a /
, Git will ignrore files that match anywhere in your directory tree.
If you want to ignore only config.php in the top-level directory, you can add a leading slash to ensure that it only matches at the top level:
/config.php
As the .gitignore
documentation (man gitignore
) states:
- If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file).
- Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".
- A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
Upvotes: 2
Reputation: 640
Adding !system/library/config.php as suggested by @VonC should work. As for why it's ignored in the first place, try looking at your global gitignore rules or file. It's possible there are leftovers from an older project.
Upvotes: 0