Let's say, you have some commit in your history with hash a1a1a1 (btw. you may get to know your commits' hashes with this command: git log --graph --oneline
). This commit has binary files in it which you want (quite fairly) to exclude form your history. This is how to do it:
Firstly, create an empty commit before your very first commit:
git rebase --root --onto $(git commit-tree -m 'root_commit' $(git hash-object -t tree /dev/null))
Let's say, this root commit has got hash of a2a2a2. Note that.
Secondly, delete the files (binaries, etc.) and commit the deletion with this command:
git commit --fixup a1a1a1
Finally, perform the squash:
git rebase -i --autosquash a2a2a2
You're done.
P.S.: This action is to change every hash sum of every commit after the a2a2a2. This is why you can only modify your commit history this deeply only if you're the only developer of this project, or you are in close relations with other members of your team so you can settle it :-)