when .gitignore just ignores you!

André da Silva Carrilho
TAGGED IN git, gitignore

Everyone that once worked with git already stumbled upon this problem. You added some rules to .gitignore file to be excluded in the next commits but the files still appear on the src tree. Well, the thing is that those files were previously added to the tree and .gitignore only works for new files.

You can use git clean but what that will do is physically delete the files from the disk and not just ignore them, which is what we want. The solution is clean flush the cache by running the following command:

git rm -r –cached .  

And then committing again:

*git commit -m “your super cool commit message” *

This will eliminate all references that were cached for .gitignore and will allow git to start from scratch.