I didn't encounter Git until the end of high school and it wasn't until a few years later that I actually understood how to use it properly. One of the biggest things I missed was the power of .gitignore. This lead to many wayward bin/ and gen/ commits and unnecessarily large repositories.

Fast forward to the present predicament: bulk cleaning of past commits.

  1. Add the .gitignore file you should have way back when.
    Github .gitignore Collection
    Base OS .gitignore Sample
  2. Apply the new .gitignore rules to all commits:
    git filter-branch --force --index-filter \
    'git ls-files -ci --exclude-from=/path/to/repository/.gitignore -z | xargs -0 git rm --cached' \
    --prune-empty --tag-name-filter cat -- --all
    If Git does not allow you to use the .gitignore file from within the repository then you will need to copy it into a different directory, update the path in the sample, and re-run it.
    See Reference section below for details on the above code sample
  3. Overwrite remote repository:
    git push origin --force --all
  4. [Optional] Add Git alias to apply .gitignore changes in the future
    Open Git configuration file vi ~/.gitconfig
    If the alias section does not exist, you will need to add it.
    [alias]
            apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0r git rm --cached
    Save your changes

Reference:
Github Help: Purging a File from Repository History
stackoverflow: Applying .gitignore to Committed Files