Skip to content

Instantly share code, notes, and snippets.

@gojimmypi
Created June 22, 2018 23:50
Show Gist options
  • Save gojimmypi/6b984539f5d4bb0fd2327d14f1334965 to your computer and use it in GitHub Desktop.
Save gojimmypi/6b984539f5d4bb0fd2327d14f1334965 to your computer and use it in GitHub Desktop.
Delete a git file
#!/bin/bash
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch FILE_TO_DELETE.TXT' --prune-empty --tag-name-filter cat -- --all
# see https://stackoverflow.com/questions/2004024/how-to-permanently-delete-a-file-stored-in-git
#
# "This command will run the entire history of every branch and tag, changing any commit that involved the file,
# and any commits afterwards. Commits that are empty afterwards (because they only changed the Rakefile) are removed entirely."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment