Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

Git Practice: Remove all build results from all commits.

Tags: git, visual-studio

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.


See also

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