Skip to content

Instantly share code, notes, and snippets.

@saidsef
Created August 28, 2022 19:52
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 saidsef/f4c6ac51f03e43180b85fb57bb12a1c3 to your computer and use it in GitHub Desktop.
Save saidsef/f4c6ac51f03e43180b85fb57bb12a1c3 to your computer and use it in GitHub Desktop.
Git remove file from repo and history

To remove a file from the current commit or HEAD but if you want remove entirely from the repository’s history then you need to run couple of commands.

git filter-branch --index-filter \
    'git rm -rf --cached --ignore-unmatch path_to_file' HEAD

This will rewrite your git history to remove the file

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