How to clear git cache
Today, We are going to learn how we can clear git cache gitignore using the commands. Remove Git cache is useful when you need to add new file on gitignore. Sometimes, We forgot to add gitignore files during the GIT setup. We realised that after pushing the code on Git server and we add those files on gitignore file.
However, when we are pushing the code we realised some of the files are still showing even we added on the gitignore file. In this case, You may need to remove git cache.
How to clear git cache gitignore
1) Remove Git Entire Cache
We are going to remove entier git cache by following the commands.
git rm -r --cached . git add . git commit -am 'git cache cleared' git push origin branch_name
It will remove all files listed on the gitignore file from the repository.
2) Specific file from cache
We are going to remove specific files cache from the git repository instead of the entire cache.
git rm --cached database.php git add --all git commit -m "Remove the database config file cache" git push origin branch_name
In this tutorial, you learn how to remove ignore files from the git repository and it will help when you update the .gitignore file by git remove command.
In this article, you will learn what to do if fill doesn’t remove after adding into gitingore file. Just follow the above commands and then check the all files listed into gitignore file was removed.
When you perform the above command git will remove all files from cache and then add all files again except the files that listed on the gitingore file.
I hope this article useful for you. Please let us know if anything was missing or wrong by comment.