Search code examples
gitgitignore

File "A.gitgnore" is not ignoring files


I made a gitignore file called A.gitignore in my repo's root directory to ignore .dbf files and anything in a subdirectory called NFIRS.
The gitignore content is two lines:

*.dbf
NFIRS/

Now I committed and pushed this gitignore. After committing and pushing, whenever I make a .dbf file such as test.dbf in the root directory (filenames that have never been committed) GitHub Desktop still wants to track and commit this new file. git add . in a terminal window also fails to implement the gitignore. It also does not ignore newly created sub-dirs called NFIRS (after ensuring any previous tracking is cleared).

I've tried multiple times in terminal in the root directory:

git rm -r --cached .
git add .
git commit -m "test"

and this does not fix the issue (so again, not the simple issue of .gitignore ignoring previously tracked files)

I'm a little at a loss for how .gitignore is supposed to work.


Solution

  • .gitignore isn't an extension - it's the exact name you should use (following the POSIX convention that a file starting with a . is a hidden file).

    A.gitignore has no special meaning in Git, and as you have seen, Git doesn't ignore the files listed in it.