5

I’m using git in my ASP.NET MVC project.

I want no files from debug, bin or config folder to show in the “Pending Chages” dialog so I will not have to commit them to my repository.

These files are machine specific specially the config folder.

I tried to add the following to .gitignore:

myproject\bin**
myproject\obj**
myproject\config\**

This did not work because all files under all three folders are still displayed after each build or config changes.

What am I doing wrong?

Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
Mortalus
  • 10,574
  • 11
  • 67
  • 117

1 Answers1

12

Remove the ** from the dir name (also, I use forward slashes, don't know if that makes a difference).

Remember to remove all the offending files that might be in your repository already. A delete and commit should take care of it.

Also, if you have multiple projects you can get all bins ignored by not putting the project name in front. This should work:

bin
obj
config

This looks like the definitive SO answer: How do I ignore files in a directory in Git?

Community
  • 1
  • 1
mcalex
  • 6,628
  • 5
  • 50
  • 80
  • did as you said but i'm still getting all the files at the panding changes screen after I make a build. @mcalex – Mortalus Dec 01 '12 at 10:33
  • 2
    I don't know. Maybe you need to tell it to remove those files before they get put in the repo. Can you delete them and commit, and then see whether .gitignore does what it should? – mcalex Dec 01 '12 at 10:42
  • Thanks worked like a charm, just add that to your answer so it will be complete. – Mortalus Dec 01 '12 at 10:49
  • I believe the ** only really makes sense "in between" directories: /foo/**/bar/ will ignore any bar directory under foo but will include any bar directory under foofoo – enorl76 Sep 16 '13 at 13:59