Tuesday, May 26, 2020

Git : Remove cached files from Repository

While working on a GIT repo, many times we face a issue where we have previously included some files in GIT and now we want to remove the same files from GIT for some reason. Also if we add those files to git ignore file but still sometime they are not ignored by GIT.

This happens sometimes due to the cache on our working GIT repo. To solve this issue permanently we can run the below given commands sequentially and step by step in GIT Bash or any other window which supports git commands.
	git rm -r --cached .
git add .
git commit -am 'Cleared GIT Cache'

After executing the above commands sequentially and step by step the GIT cache will get clear and the files will get removed from GIT. Do consider taking a backup of source code in case you want to revert again back to original as it was.

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...