Category Archives: Git

Re-apply gitignore on already pushed files

Imagine the scenario you pushed your whole project to git and you realise there is no .gitignore, all the miscellaneous, unnecessary files are already in your repo. You quickly add the .gitignore file, but nothing happens!

This is because you first need to clear your cache:

git rm -r --cached .

Now you can re-add (better to say clean) you files with the following command:

git add .

You should see many files to be removed from you instance. Now you can do your commit-push as usual.

Happy coding!