The behavior of git-filter-branch may be unexpected, as you have discovered, and it will not protect you from unforeseen consequences when it starts.
Instead, I recommend using BFG Repo-Cleaner , a simpler, faster option specifically designed to remove files from Git history. One way to make your life easier is to not delete or modify in any way the files in your last commit .
You should follow the instructions, but the main bit is just that: download the BFG jar (requires Java 6 or higher) and run the following command:
$ java -jar bfg.jar --delete-files *{mode1v3,pbxuser} my-repo.git
Any file matching this expression in the history of your repository that is also not in your last commit will be deleted. Then you can use git gc to delete dead data:
$ git gc --prune=now --aggressive
BFG, as a rule, is much easier to use than git-filter-branch - the parameters are configured around these two common use cases:
- Delete Crazy Big Files
- Removing Passwords, Credentials, and Other Personal Data
Full disclosure: I am the author of BFG Repo-Cleaner.
source share