Git Practice: Remove all build results from all commits.

Sometimes we make mistakes and need to correct them. Committing and pushing build results is one of these. This requires two steps:

Remove build results from the local and remote repository.

The build results include at least the /bin and /obj directories.

Check whether any commits includes those folders:

git log --oneline --name-only --all -- bin -20

git log --oneline --name-only --all -- obj -20

Remove all files in bin.

git filter-branch --index-filter 'git rm --cached --ignore-unmatch bin/*' -- --all

Make sure anyone who has based commits on rewritten ones is up to date.

Todo

See also

http://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery > See the "removing objects" section