One day I setup gitignore for existing project/repository, the expected result is all file/folder defined on gitignore is ignored by git when doing commit or push, but when I commit/push the code, file and folder defined on gitignore is still pushed to repository. After some google I found that git is likely caching this, and we need to delete this cache to make it work. We can delete this cache with this command :
git rm -r --cached . git add . git commit -m "fixed untracked files"
After command above git will exclude ignored file with in gitignore.