Skip to content

Instantly share code, notes, and snippets.

@minlaxz
Created November 12, 2021 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minlaxz/fe26f24af42b6fe8695748e4ebc0a6fd to your computer and use it in GitHub Desktop.
Save minlaxz/fe26f24af42b6fe8695748e4ebc0a6fd to your computer and use it in GitHub Desktop.
Completely remove a file from Git history

I am removing .env file from local git history.

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD

To push this to remote,

git push --force

Reference

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