Skip to content

Instantly share code, notes, and snippets.

@brokenmold
Last active January 29, 2023 16:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brokenmold/994d58ccb4160e63ffa3f3a05ce383a5 to your computer and use it in GitHub Desktop.
Save brokenmold/994d58ccb4160e63ffa3f3a05ce383a5 to your computer and use it in GitHub Desktop.
Wipe oops'd .env's from GitHub
*** Removes most recent unpushed env commit & adds env to gitignore ***
echo '.env' >> .gitignore
git rm -r --cached .env
git add .gitignore
git commit -m 'untracking .env'
git push origin master
*** Removes all env instances from commit history ***
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment