How I usually proceed:
Actually, to remove some files from complete history, I use the following script (which I call git-crunch) :
#!/bin/bash
#
# git crunch <filenames>
#
git filter-branch --index-filter "git rm --cached --ignore-unmatch $*"
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git fsck --full --unreachable
git repack -A -d
git gc --aggressive --prune=now
It works perfectly to remove specified files from (complete) history.
The context is:
I have 1 project which breaks into 4 branches. Here is a summary network diagram which shows up 2 of the 4 maintained branches:
┏ a937fd9 (1 year, 9 months ago) <new repo>
...
60 commits later, we create a branch "probe" which is displayed at left of the network
...
┣━┓
┣ ┃ c483a22 (8 months ago)
┃ ┣ f7b402c (3 months ago)
...
┃ ┣━┓
┣ ┃ ┃ 38bb93d (11 days ago)
┣ ┃ ┃ 1ef8202 (11 days ago)
┃ ┃ ┣━[remotes/origin/S...H_adjust]──adb243f (8 days ago)
┃ ┣ ┃ cd02775 (8 days ago)
┃ ┣━┛
┃ ┣ f9e40a3 (8 days ago)
┃ ┣ a30eb6f (7 days ago)
┃ ┣━[remotes/origin/S...H_verif]──4a3fe66 (7 days ago)
┃ ┗━[remotes/origin/HEAD]──[remotes/origin/master]──b452f85 (7 days ago)
┣ 91477ae (4 days ago)
┗━[HEAD]──[probe]──[remotes/origin/probe]──366c890 (48 minutes ago)
My probolem is:
I have 3 huge files in this repository which could be removed from the beginning (creaton of the repository) but if I use my script, it will only run in one branch, and it will recreate 4 separate branches from the beginning until last commit, which happened today.
My question:
How can I achieve these 3 files removal frmo my whole history without separating my branches from the beginning? Or, is there a way to rewrite the entire hisotry and remove files from all branches at once so I can keep my evolution network and "shared" commits intact (so I don't get my 61 first commits duplicated four times)?