问题
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.
回答1:
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.*/
回答2:
Just found this - https://github.com/github/gitignore
Specifically this - https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
回答3:
You should ignore:
- the
bin
directory - the
obj
directory *.suo
*.user
来源:https://stackoverflow.com/questions/1677113/files-to-ignore-when-using-visual-studio-with-git