当Git与Visual Studio解决方案(.sln)和项目一起使用时,我应该在.gitignore中包含哪些文件?


当前回答

我明白这是一个老问题,还在分享一个信息。在Visual Studio 2017中,只需右键单击解决方案文件,并选择将解决方案添加到源代码控制

这将向源文件夹中添加两个文件。

.gitattributes .gitignore

这是最简单的方法。

其他回答

下面是我在。net项目中为我的.gitignore文件所使用的。

[Oo]bj/
[Bb]in/
*.suo
*.user
/TestResults
*.vspscc
*.vssscc

这几乎是一个全MS的方法,它使用内置的Visual Studio测试器,并且一个项目也可能有一些TFS绑定。

我在c#项目中使用下面的.gitignore。在需要时添加其他模式。

[Oo]bj
[Bb]in
*.user
*.suo
*.[Cc]ache
*.bak
*.ncb
*.log 
*.DS_Store
[Tt]humbs.db 
_ReSharper.*
*.resharper
Ankh.NoLoad

如果您在解决方案中使用dbproj,则需要添加以下内容:

#Visual Studio DB Project
*.dbmdl
[Ss]ql/

来源: http://blogs.msdn.com/b/bahill/archive/2009/07/31/come-visit-revisit-the-beer-house-continuous-integration.aspx

我明白这是一个老问题,还在分享一个信息。在Visual Studio 2017中,只需右键单击解决方案文件,并选择将解决方案添加到源代码控制

这将向源文件夹中添加两个文件。

.gitattributes .gitignore

这是最简单的方法。

某些项目可能需要添加*。显到他们的视觉工作室gitignore。输入输出文件。

这是因为新项目的一些Visual Studio项目属性被设置为生成清单文件。

参见“在Visual Studio中生成清单”

但是如果您已经生成了它们,并且它们是静态的(不会随着时间而改变),那么从.gitignore文件中删除它们是个好主意。

这就是Git for Windows这样的项目刚刚做的事情(适用于Git 2.24, 2019年第四季度)

参见Johannes Schindelin (dscho)的commit aac6ff7(2019年9月05日)。 (由Junio C Hamano—gitster—在commit 59438be中合并,2019年9月30日)

.gitignore: stop ignoring .manifest files On Windows, it is possible to embed additional metadata into an executable by linking in a "manifest", i.e. an XML document that describes capabilities and requirements (such as minimum or maximum Windows version). These XML documents are expected to be stored in .manifest files. At least some Visual Studio versions auto-generate .manifest files when none is specified explicitly, therefore we used to ask Git to ignore them. However, we do have a beautiful .manifest file now: compat/win32/git.manifest, so neither does Visual Studio auto-generate a manifest for us, nor do we want Git to ignore the .manifest files anymore.