1

I have several files that are too big to commit to github and now I am forced to rewrite the history using git filter branch.

I have about 4 files that are above 100MB csv files that I would prefer to just remove from the history. I have files name: story_a002.csv, input_0019.csv, charlet.csv and model_892.csv

I know I am able to use this command below but I must use it one at a time. Once the rewrite is complete I have to push the changes; unfortunately, because I have to rewrite all of them first othewise I will get a File Too Large github issue.

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch <filename>

Is there a way to chain this so I can rewrite once and do a single push?

Potion
  • 785
  • 1
  • 14
  • 36

1 Answers1

4

First, You might consider the new git filter-repo, which will replace the old git filter-branch or BFG.

It has many usage examples, including path-based filtering:

To keep all files except these paths, just add --invert-paths:

git filter-repo --path aFileToRemove --invert-paths

Try it with multiple path (to remove all your files in one command), and then force push.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • A bit emberassing as I did this weeks ago but I dont recall how to push changes. I was able to rewrite it using a command with multiple paths like this `git filter-repo --path system/ftb/logs/homeTest2_log_2020-07-06--21-34-56.csv --path system/ftb/logs/log_boom_1595882264736.csv --path system/ftb/python/logs/log_boom_1598049968926.csv --path system/servo/logs/log_servo_1595882275794.csv --invert-paths` however when I try to push my stream is broken. So i reconnect it but a pull is required. How do I push my changes after? – Potion Nov 02 '20 at 16:48
  • @Potion After a filter repo, you should force push: `git push --force` (assuming you are the only one working on that branch, or that other colleagues are well aware of that rewrite) – VonC Nov 02 '20 at 16:49