Skip to content

Instantly share code, notes, and snippets.

@liitfr
Created July 14, 2017 19:20
Show Gist options
  • Save liitfr/39c4b0df7be7bfdde1273125f4169dbb to your computer and use it in GitHub Desktop.
Save liitfr/39c4b0df7be7bfdde1273125f4169dbb to your computer and use it in GitHub Desktop.
you accidentally commited your .env file in a previous commit, and you want it to disappear ? 🕵

Answer

Execute this code in your repository

git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch .env' \
--prune-empty --tag-name-filter cat -- --all

don't forget to replace .env by expected name.

@bjorntirsen
Copy link

My .env file still shows in the commit on GitHub after running above code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment