Why is the .gitignore file being ignored?

I’ve started working on a Web API tutorial that I learned about at last week’s Microsoft Build conference. This project uses Visual Studio Code. After creating the project locally, I got a .gitignore file for Visual Studio from off GitHub. However, three times already when committing code to my local repo, Git (GitLens in VS Code) insists that it must include all .dll’s and .pdb files. Both of which are prohibited in the .gitignore file.

Why is it the .gitignore file is being ignored? Is there a .gitignore file for VS Code?

1 Like

I believe I’ve found the solution. I thought I had put the .gitignore at the root of the repo, but I’ve discovered that I didn’t. It was in the root of the project I was working. I’ve moved the .gitignore file to root of the solution.


I’m working with it now. Even though the .gitignore file is at the root of the solution, when I do a commit it complains about the .dll, .pdb, .json, .and .cache files not being staged. I would have thought that wouldn’t happen now that I’ve got the ignore file in the correct place.

So, what’s going on?

are you able to post your code on GitHub so we can take a look (manually ignore the dlls/pdbs for now)?

Here’s some of the .gitignore file now in the root of my solution. (It’s 388 lines long, so I thought it best to restrict how much I share here):

##Ignore Visual Studio temporary files, build results, and
##files generated by popular Visual Studio add-ons.

##Get latest from gitignore/VisualStudio.gitignore at 3bb7b4b767f3f8df07e362dfa03c8bd425f16d32 · github/gitignore · GitHub

#Build results

#Files built by Visual Studio

#Visual Studio cache files
#files ending in .cache can be ignored

That looks fine, but I was wondering if the file was really called .gitignore and not .gitignore.txt if you have your windows settings hiding the file extension. If you can commit an example to GitHub then it will be easier to rule things out