Search code examples
git

.gitignore Files Still Show Up in Untracked List


I have some files that were being tracked by Git:

  • content/.htaccess
  • admin/cache/
  • db_changes.docx

But then I decided I wanted Git to ignore them. So I added them to the .gitignore file, then ran these commands:

git rm --cached content/.htaccess
git rm -r --cached admin/cache/
git rm --cached db_changes.docx

Then I committed the repo. But if I run git status again, those files still show up in the "untracked files" list.

I ran:

git ls-files . --ignored --exclude-standard --others

to list .gitignore files, but nothing showed up. I'm sure I put them in the .gitignore file correctly, so I'm really confused/frustrated.


Solution

  • My .gitignore file was in the wrong place. I had it in the root of my .git directory, not the root of my repo.