'git remove a file's history content

I have a file in my git repo which was used to keep credentials. We then modified the file and convert it into a template file and remove all the credentials from it.

Now we want to keep the file as it is but want to clean the history of this file which are having the credentials(clean history for this git file from a commit point) as Someone can go the file in the UI and click on history and see the credentials.

Is there any git command to achieve this?

I tried to search but could not find anything.

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source