Seems this page still shows up on the top of Google search after so many years...
Modern versions of Git support nesting .gitignore files within a single repo. Just place a .gitignore file in the subdirectory that you want ignored. Use a single asterisk to match everything in that directory:
echo "*" > /path/to/bin/Debug/.gitignore
echo "*" > /path/to/bin/Release/.gitignore
If you've made previous commits, remember to remove previously tracked files:
git rm -rf /path/to/bin/Debug
git rm -rf /path/to/bin/Release
You can confirm it by doing git status
to show you all the files removed from tracking.