Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. How and when you need to clear Git cache. Whenever you want to add any file to Git Ignore file ongoing project at that time you need to clear cache after adding it to ignore. When you think your git is messed up and acting funky at that time you need to clear cache. Just follow below command for git clear cache.
Before, clearing git cache makes sure your code is committed and push to the branch.
Clear Git Cache
git rm -r --cached .
git add .
git commit -am 'git cache cleared'
git push origin master
If you face any issue after following this steps write below the comment.