DEV Community

Faisal Ahmed
Faisal Ahmed

Posted on

How to Completely Remove .env/secrets File from Github Repository When Pushed By Mistake

steps:

  1. git rm -r --cached .env
  2. git add .
  3. git commit -m"remove env file"
  4. git push

Top comments (1)

Collapse
 
endorama profile image
Edoardo Tenani • Edited

Unfortunately the steps you mention here are not enough to remove pushed credentials. Those steps remove them from the latest version of your branch but is it still possible to recover them from the git history.

I suggest you to have a look at GitHub Docs about it: docs.github.com/en/authentication/...