If you try to .gitignore
files after committing them, you’ll notice it doesn’t work: git
still tracks changes to those files and they still appear in your remote repo. What to do?
You need to remove those files from git
’s cache.
You can remove specific files or folders:
git rm --cached <file>
git rm -r --cached <folder>
Or just clear the whole cache:
git rm -r --cached .
Then commit your changes so git
knows which files it should track going forward:
git add .
git commit -m "fix: stop tracking ignored files"
Related
- Clear .gitignore cache • Ainsof So’o 👨💻
- Ignore files that have already been committed to a Git repository • Stack Overflow 💬
- How do I make Git forget about a file that was tracked, but is now in .gitignore? • Stack Overflow 💬