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. When you want to add any file/folder to git ignore at that time you need to clear git cache. When you think your git is messed up and acting funky you need to clear git cache. Just follow below command for the clear cache.
Make sure before clear cache commits your code and push it to the server.
git rm -r --cached . git add . git commit -am 'git cache cleared' git push origin master
If you face any kind of issue after following above step please write below the comment.