Posts

Showing posts from February, 2021

How to remove files completely from git repository history

 If you want to remove a file from GIT, it is straight forward, the simple command git rm will remove tracked files from the git index, but it leaves a foot print in the history, you can traverse back and get the file back. Suppose if you wrongly committed a file, with some valid keys, deleting the file alone is not going to help. If it is a public repository, then the issue will be more, since there are many bots running on the web, which scan entire repository to look for sensitive keys like (AWS/GCP/Azure keys, Valid IP address etc..). So to get rid off the old foot print completely, we need to do the following steps. git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch FILE_PATH" HEAD git push -all The first command is a time consuming one, it's based on the number of commits for the files, since it has to go check each and every commit to erase the foot print. That's all, you won't see the file history again. Happy Programming...!!!