Removing .env file from Git history To remove a .env file from Git history, you can use the git filter-branch or git filter-repo command to rewrite the repository's history and exclude the file.
How to revert pushed commit from the repo? Despite all the fixes you try, faulty commits occasionally make it into the central repository. Still, this is no reason to despair, since git offers an easy way to revert single or multiple commits.