Skip to content

Instantly share code, notes, and snippets.

@muhammadghazali
Last active February 26, 2020 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save muhammadghazali/5311500 to your computer and use it in GitHub Desktop.
Save muhammadghazali/5311500 to your computer and use it in GitHub Desktop.
Deleting file from Git history

Example 1

Deleting .env:

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

Example 2

Deleting .env inside the app directory:

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

References

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