Which files should I include in .gitignore
when using Git in conjunction with Visual Studio Solutions (.sln
) and Projects?
|
||||
See the official GitHub's "Collection of useful .gitignore templates". The |
|||||||||||||||||||||
|
There's an online tool which allow you to generate .gitignore file based on your OS, IDE, language, etc. Take a look at http://www.gitignore.io/. On 8/20/2014, here's the file that is generated for Visual Studio + Windows.
|
||||
|
I use the following .gitignore for C# projects. Additional patterns are added as and when they are needed.
|
|||||||||||||||||
|
For those interested in what Microsoft thinks should be included in the gitignore, here's the default one which
|
||||
|
While you should keep your NuGet packages.config file, you should exclude the packages folder:
I typically don't store binaries, or anything generated from my source, in source control. There are differing opinions on this however. If it makes things easier for your build system, do it! I would however, argue that you are not versioning these dependencies, so they will just take up space in your repository. Storing the binaries in a central location, then relying on the packages.config file to indicate which version is needed is a better solution, in my opinion. |
|||||||||||||||||
|
I prefer to exclude things on an as-needed basis. You don't want to shotgun exclude everything with the string "bin" or "obj" in the name. At least be sure to follow those with a slash. Here's what I start with on a VS2010 project:
And only because I use ReSharper, also this:
|
|||||
|
Added InstallShield ignores for the build deployment. InstallShield is the new direction Microsoft is headed over Visual Studio Installer, so we've started using it on all new projects. This added line removes the SingleImage installation files. Other InstallShield types may include DVD distribution among others. You may want to add those directory names or just [Ee]xpress/ to prevent any InstallShield LE deployment files from getting into the repo. Here is our .gitignore for VS2010 C# projects using Install Shield LE with SingleImage deployments for the installer:
|
|||||||||||||
|
On Visual Studio 2015 Update 3, and with Git extension updated as of today (2016-10-24), the .gitignore generated by Visual Studio is:
|
|||||
|
Here's an extract from a
Perhaps this question should be Community Wiki, so we can all edit together one master list with comments about which files should be ignored for which types of project? |
|||||||||
|
Credit to Jens Lehmann for this one - if you keep source directories separate to your compiler project files and build output, you could simplify your .gitignore by negating it:
You don't say what language(s) you're using, but the above should work for C++ projects. |
|||||
|
Late to the party here, but I also find that I use the following. Some may only be useful for hiding sensitive files when pushing to a public remote.
|
|||||||||||||
|
I know this is an old thread but for the new and the old who visit this page, there is a website called gitignore.io which can generate these files. Search "visualstudio" upon landing on the website and it will generate these files for you, also you can have multiple languages/ides ignore files concatenated into the one document. Beautiful. |
||||
|
If you are using a dbproj in your solution you will want to add the following:
|
||||
|
There is a shortcut in Visual Studio, because it supports Git out of the box in 2015 or above. For new solutions (or some which don't have Right-click on your solution and select It automatically initializes The text will appeared in the VS console:
Done! |
||||
|
Here is what I use in my .NET Projects for my
This is pretty much an all MS approach, that uses the built in Visual Studio tester, and a project that may have some TFS bindings in there too. |
||||
|
As mentioned by another poster, Visual Studio generates this as a part of its .gitignore (at least for MVC 4):
Since your project may be a subfolder of your solution, and the .gitignore file is stored in the solution root, this actually won't touch the local database files (Git sees them at
|
|||||
|
.sln
files checked in, we get noise diffs such as-# Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0
Can this be avoided? – Jean Jordaan Feb 26 '16 at 7:52