14

I've installed Git to do some development using Visual Studio 2008. Most of the work will be new development but we do have some old projects from prior to VS2005 that I want to bring over into the new repository. There is an existing thread about general VS/Git integration but my question is limited to the .gitignore file and Visual Studio.

My question has two parts:

  • What entries should be included in the .gitignore file to cover the Visual Studio specific files like binaries, assemblies, debug files, etc? Some were covered in the thread mentioned above but is there a comprehensive set?

  • In what situations have you needed to exclude files globally, or for a single repository, or using the environment variable?

I already know the HOW. Here is an excerpt from the Git user-manual on ignoring files.

If you wish the exclude patterns to affect only certain repositories (instead of every repository for a given project), you may instead put them in a file in your repository named .git/info/exclude, or in any file specified by the core.excludesfile configuration variable. Some git commands can also take exclude patterns directly on the command line. See gitignore(5) for the details.

Community
  • 1
  • 1
Kelly S. French
  • 12,198
  • 10
  • 63
  • 93
  • Since this is something that changes over time, I think the best answer to this question is a list that is maintained by the community. Therefore, can I suggest that you mark the 'github' answer below as the correct answer to this question. – Rick Arthur Dec 26 '16 at 20:09

4 Answers4

16

Just found this - https://github.com/github/gitignore

Specifically this - https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

Nafeez Abrar
  • 1,045
  • 10
  • 27
bluekeys
  • 2,217
  • 1
  • 22
  • 30
  • This is very good. The list is complete and `.dll` and `.exe` files are not ignored for no reason. Typical build locations are ignored instead. – pbalaga Jan 26 '14 at 14:50
  • Agreed, use the community-curated one when you can, because it (theoretically) represents a consensus of best practices, and will include things you never would've thought of on your own. However, **make sure** things _you_ expect to be committed are _actually_ committed (and not ignored). Related is [karan/joe](https://github.com/karan/joe), a standalone Go executable which downloads `.gitignore`s from the same github/gitignore repository. It's perfect for people who switch among multiple languages frequently for new projects. – TheDudeAbides Dec 12 '18 at 01:23
8

In GitExtensions the default .gitignore is this. It can be a bit shorted by removing most individual file extensions and only exclude the directories they are in.

*.obj
*.exe
*.exp
*.pdb
*.dll
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.zip
[Dd]ebug*/
*.lib
*.sbr
Thumbs.db
[Ll]ib/
[Rr]elease*/
[Tt]est[Rr]esults/
_UpgradeReport_Files/
_ReSharper.*/
Kelly S. French
  • 12,198
  • 10
  • 63
  • 93
user195595
  • 1,294
  • 1
  • 8
  • 2
7

You should ignore:

  • the bin directory
  • the obj directory
  • *.suo
  • *.user
Michael Hackner
  • 8,605
  • 2
  • 27
  • 29
0

If you have node installed, uou can run npx gitignore to generate .gitignore files:

npx gitignore VisualStudio
KyleMit
  • 30,350
  • 66
  • 462
  • 664