I know this old post, but I still had this problem, and using MsysGit 1.8.0 I was not able to use the accepted @manojlds answer.
It seems that the only templates that exclude all bin folders at any depth are [Bb]in and [Bb]in/ . According to the gitignore man page, the one that has a trailing slash is the most correct, since it will only match directories, not files named "bin", As soon as I try to add additional levels to the template, for example [Bb]in/* , it stops matching at any depth and becomes relative to the location of the .gitignore file, as on the manual page.
Now, assuming I have an [Bb]in/ entry in my global .gitignore file, the best way I found to not write a separate file template (e.g. .refresh files) in a separate bin folder is to create another .gitignore create one directory above the bin folder (i.e. the project directory) and paste the following entries:
![Bb]in/ [Bb]in/* ![Bb]in/*.refresh
Our folders with the folders of the website project never contain subfolders such as Debug or Release, but I tested them and it still ignores the subfolders in the bin folder if necessary.
If I use only the second and third entries, as suggested by the accepted answer, this will not work. An intuitive explanation is that the first record deletes this particular bin folder from the global globe, so its contents will be included, then the second record will work as desired, since in this case it refers to the .gitignore file, and the third record deletes the necessary templates from globe created by the second entry.
Blued
source share