etc./StackOverFlow

Visual Studio 프로젝트 및 솔루션용 .gitignore

청렴결백한 만능 재주꾼 2023. 5. 4. 22:14
반응형

질문자 :Community Wiki


Visual Studio 솔루션( .sln ) 및 프로젝트와 함께 Git 을 사용할 때 .gitignore 어떤 파일을 포함해야 합니까?



공식 GitHub의 "유용한 .gitignore 템플릿 모음"을 참조하세요.

.gitignore 는 여기에서 찾을 수 있습니다.
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore


Community Wiki

OS, IDE, 언어 등에 따라 .gitignore 파일을 생성할 수 있는 온라인 도구가 있습니다. http://www.gitignore.io/를 살펴보십시오.

여기에 이미지 설명 입력

2014년 8월 20일에 Visual Studio + Windows용으로 생성된 파일은 다음과 같습니다.

 # Created by http://www.gitignore.io ### VisualStudio ### ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.sln.docstates # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ build/ bld/ [Bb]in/ [Oo]bj/ # Roslyn cache directories *.ide/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* #NUNIT *.VisualState.xml TestResult.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c *_i.c *_p.c *_i.h *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opensdf *.sdf *.cachefile # Visual Studio profiler *.psess *.vsp *.vspx # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # JustCode is a .NET coding addin-in .JustCode # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # NCrunch _NCrunch_* .*crunch*.local.xml # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore **/packages/* # except build/, which is used as an MSBuild target. !**/packages/build/ # If using the old MSBuild-Integrated Package Restore, uncomment this: #!**/packages/repositories.config # Windows Azure Build Output csx/ *.build.csdef # Windows Store app package directory AppPackages/ # Others sql/ *.Cache ClientBin/ [Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.dbproj.schemaview *.pfx *.publishsettings node_modules/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm # SQL Server files *.mdf *.ldf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings # Microsoft Fakes FakesAssemblies/ ### Windows ### # Windows image file caches Thumbs.db ehthumbs.db # Folder config file Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ # Windows Installer files *.cab *.msi *.msm *.msp

Community Wiki

C# 프로젝트에 다음 .gitignore를 사용합니다. 추가 패턴은 필요할 때 추가됩니다.

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

Community Wiki

Microsoft 가 gitignore에 포함해야 한다고 생각하는 항목에 관심이 있는 사용자를 위해 Visual Studio 2013 RTM 이 새 Git 리포지토리를 만들 때 자동으로 생성하는 기본 항목이 있습니다.

 ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.sln.docstates # Build results [Dd]ebug/ [Rr]elease/ x64/ build/ [Bb]in/ [Oo]bj/ # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets !packages/*/build/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* *_i.c *_p.c *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.log *.scc # Visual C++ cache files ipch/ *.aps *.ncb *.opensdf *.sdf *.cachefile # Visual Studio profiler *.psess *.vsp *.vspx # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # NCrunch *.ncrunch* .*crunch*.local.xml # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.Publish.xml # NuGet Packages Directory ## TODO: If you have NuGet Package Restore enabled, uncomment the next line #packages/ # Windows Azure Build Output csx *.build.csdef # Windows Store app package directory AppPackages/ # Others sql/ *.Cache ClientBin/ [Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.[Pp]ublish.xml *.pfx *.publishsettings # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file to a newer # Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm # SQL Server files App_Data/*.mdf App_Data/*.ldf #LightSwitch generated files GeneratedArtifacts/ _Pvt_Extensions/ ModelManifest.xml # ========================= # Windows detritus # ========================= # Windows image file caches Thumbs.db ehthumbs.db # Folder config file Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ # Mac desktop service store files .DS_Store

참조: MSDN에 기본 .gitignore 파일 추가


Community Wiki

NuGet packages.config 파일을 유지해야 하지만 packages 폴더는 제외해야 합니다.

 #NuGet packages/

나는 일반적으로 소스 제어에 바이너리 또는 내 소스에서 생성된 모든 것을 저장하지 않습니다. 그러나 이에 대해서는 의견이 엇갈린다. 빌드 시스템을 더 쉽게 만들 수 있다면 그렇게 하십시오! 그러나 나는 당신이 이러한 의존성을 버전화하지 않는다고 주장하고, 그래서 그것들은 당신의 리포지토리에서 공간을 차지할 것입니다. 바이너리를 중앙 위치에 저장한 다음 packages.config 파일에 의존하여 어떤 버전이 필요한지 표시하는 것이 더 나은 솔루션이라고 생각합니다.


Community Wiki

나는 이것이 여전히 정보를 공유하는 오래된 질문이라는 것을 이해합니다. Visual Studio 2017에서는 솔루션 파일을 마우스 오른쪽 버튼으로 클릭 하고 소스 제어에 솔루션 추가를 선택할 수 있습니다.

여기에 이미지 설명 입력

그러면 소스 폴더에 두 개의 파일이 추가됩니다.

  1. .git속성
  2. .gitignore

이것이 가장 쉬운 방법입니다.


Community Wiki

나는 필요에 따라 물건을 제외하는 것을 선호합니다. 이름에 "bin" 또는 "obj" 문자열이 있는 모든 항목을 Shotgun 제외하고 싶지는 않습니다. 최소한 슬래시가 있는 것은 따라야 합니다.

VS2010 프로젝트에서 시작하는 작업은 다음과 같습니다.

 bin/ obj/ *.suo *.user

ReSharper를 사용하기 때문에 다음도 마찬가지입니다.

 _ReSharper*

Community Wiki

Visual Studio 2015 팀 탐색기 > 로컬 Git 리포지토리 > 프로젝트 > 설정 > Git > 리포지토리 설정 > 무시 및 속성 파일에서. 기본적으로 Visual Studio 솔루션에서 무시되어야 하는 항목과 함께 .gitignore 파일을 추가할 수 있습니다. 여기에 이미지 설명 입력

여기에 이미지 설명 입력


Community Wiki

Visual Studio 2015 업데이트 3에서 오늘(2016-10-24) Git 확장이 업데이트되면 Visual Studio에서 생성된 .gitignore는 다음과 같습니다.

 ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ [Xx]64/ [Xx]86/ [Bb]uild/ bld/ [Bb]in/ [Oo]bj/ # Visual Studio 2015 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUNIT *.VisualState.xml TestResult.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # DNX project.lock.json artifacts/ *_i.c *_p.c *_i.h *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opendb *.opensdf *.sdf *.cachefile *.VC.db # Visual Studio profiler *.psess *.vsp *.vspx *.sap # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # JustCode is a .NET coding add-in .JustCode # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # NCrunch _NCrunch_* .*crunch*.local.xml nCrunchTemp_* # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # TODO: Un-comment the next line if you do not want to checkin # your web deploy settings because they may include unencrypted # passwords #*.pubxml *.publishproj # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore **/packages/* # except build/, which is used as an MSBuild target. !**/packages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/packages/repositories.config # NuGet v3's project.json files produces more ignoreable files *.nuget.props *.nuget.targets # Microsoft Azure Build Output csx/ *.build.csdef # Microsoft Azure Emulator ecf/ rcf/ # Microsoft Azure ApplicationInsights config file ApplicationInsights.config # Windows Store app package directory AppPackages/ BundleArtifacts/ # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache !*.[Cc]ache/ # Others ClientBin/ [Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.dbproj.schemaview *.pfx *.publishsettings node_modules/ orleans.codegen.cs # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm # SQL Server files *.mdf *.ldf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings # Microsoft Fakes FakesAssemblies/ # GhostDoc plugin setting file *.GhostDoc.xml # Node.js Tools for Visual Studio .ntvs_analysis.dat # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml **/*.Server/GeneratedArtifacts **/*.Server/ModelManifest.xml _Pvt_Extensions # LightSwitch generated files GeneratedArtifacts/ ModelManifest.xml # Paket dependency manager .paket/paket.exe # FAKE - F# Make .fake/

Community Wiki

빌드 배포에 대해 InstallShield 무시를 추가했습니다. InstallShield는 Microsoft가 Visual Studio Installer에 대해 지향하는 새로운 방향이므로 모든 새 프로젝트에서 사용하기 시작했습니다. 이 추가된 행은 SingleImage 설치 파일을 제거합니다. 다른 InstallShield 유형에는 DVD 배포가 포함될 수 있습니다. 이러한 디렉토리 이름을 추가하거나 [Ee]xpress/만 추가하여 InstallShield LE 배포 파일이 리포지토리에 들어가는 것을 방지할 수 있습니다.

다음은 설치 프로그램에 대한 SingleImage 배포와 함께 Install Shield LE를 사용하는 VS2010 C# 프로젝트용 .gitignore입니다.

 #OS junk files [Tt]humbs.db *.DS_Store #Visual Studio files *.[Oo]bj *.exe *.pdb *.user *.aps *.pch *.vspscc *.vssscc *_i.c *_p.c *.ncb *.suo *.tlb *.tlh *.bak *.[Cc]ache *.ilk *.log *.lib *.sbr *.sdf ipch/ obj/ [Bb]in [Dd]ebug*/ [Rr]elease*/ Ankh.NoLoad #InstallShield [Ss]ingle[Ii]mage/ [Dd][Vv][Dd]-5/ [Ii]nterm/ #Tooling _ReSharper*/ *.resharper [Tt]est[Rr]esult* #Project files [Bb]uild/ #Subversion files .svn # Office Temp Files ~$*

Community Wiki

나는 이것이 오래된 스레드라는 것을 알고 있지만 이 페이지를 방문하는 신규 및 기존 사용자를 위해 이러한 파일을 생성할 수 있는 gitignore.io라는 웹사이트가 있습니다. 웹사이트에 방문할 때 "visualstudio"를 검색하면 이러한 파일이 자동으로 생성되며 여러 언어/IDE가 하나의 문서에 연결된 파일을 무시하도록 할 수도 있습니다.

아름다운.


Community Wiki

다음은 내가 작업하고 있던 최근 프로젝트 .gitignore 에서 발췌한 것입니다. 컴파일 출력을 포함하여 Visual Studio와 관련된 것으로 생각되는 것을 추출했습니다. 크로스 플랫폼 프로젝트이므로 다른 빌드 시스템에서 생성된 파일에 대한 다양한 무시 규칙이 있으며 정확하게 구분했다고 보장할 수 없습니다.

 *.dll *.exe *.exp *.ilk *.lib *.ncb *.log *.pdb *.vcproj.*.user [Dd]ebug [Rr]elease

아마도 이 질문은 Community Wiki여야 합니다. 그래서 우리는 모두 어떤 유형의 프로젝트에 대해 어떤 파일을 무시해야 하는지에 대한 의견과 함께 하나의 마스터 목록을 함께 편집할 수 있습니다.


Community Wiki

이 점에 대해 Jens Lehmann에게 감사드립니다. 소스 디렉토리를 컴파일러 프로젝트 파일과 별도로 유지하고 출력을 빌드하면 .gitignore를 부정하여 단순화할 수 있습니다.

 path/to/build/directory/* !*.sln !*.vcproj

어떤 언어를 사용하고 있는지 말하지 않지만 위의 내용은 C++ 프로젝트에서 작동해야 합니다.


Community Wiki

여기 파티에 늦었지만 다음을 사용하는 것도 발견했습니다. 일부는 공개 리모컨으로 푸시할 때 민감한 파일을 숨기는 데만 유용할 수 있습니다.

 #Ignore email files delivered to specified pickup directory *.eml #Allow NuGet.exe (do not ignore) !NuGet.exe #Ignore WebDeploy publish profiles *.Publish.xml #Ignore Azure build csdef & Pubxml files ServiceDefinition.build.csdef *.azurePubxml #Allow ReSharper .DotSettings (for non-namespace-provider properties) !*.csproj.DotSettings #Ignore private folder /Private/

Community Wiki

솔루션에서 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


Community Wiki

팀 탐색기의 설정 보기로 이동한 다음 리포지토리 설정을 선택하여 리포지토리에 대한 .gitignore 파일을 만들거나 편집할 수 있습니다. .gitignore에 대해 편집을 선택합니다.

모든 VS 특정 빌드 디렉토리 등을 무시하는 필터를 자동으로 생성합니다.

여기에 이미지 설명 입력

자세한 정보는 여기를 참조하십시오 .


Community Wiki

Visual Studio에는 2015년 이상 버전의 Git을 기본적으로 지원하기 때문에 바로 가기 가 있습니다. 새 솔루션(또는 .git 폴더가 없는 솔루션)의 경우 솔루션 탐색기 에서 소스 제어 기능을 사용하십시오.

솔루션을 마우스 오른쪽 버튼으로 클릭 하고 팝업 메뉴에서 Add Solution to Source Control...

자동으로 .git 리포지토리를 초기화하고 솔루션에 필요한 항목과 함께 .gitignore .gitattributes 파일(줄 끝 등)까지 추가합니다.

텍스트가 VS 콘솔에 나타납니다.

 A new Git repository has been created for you in C:\<path to your solution> Commit ______ created locally in repository.

완료!


Community Wiki

Visual Studio를 사용하여 .gitignore 추가

Visual Studio 및 무시 파일이 필요한 솔루션을 엽니다. 상단 메뉴에서 Git > 설정을 선택합니다.

여기에 이미지 설명 입력

위의 소스 제어 > Git 전역 설정이 선택된 Visual Studio의 옵션이 열립니다. 왼쪽 목록에서 Git Repository Settings 를 선택한 다음 Ignore file 에 대한 추가 버튼을 클릭합니다.

여기에 이미지 설명 입력

위의 내용은 일반적인 Visual Studio 설정에 대해 모든 적절한 파일이 무시된 .gitignore 파일을 추가합니다.

https://elanderson.net/2020/10/add-git-ignore-to-an-existing-visual-studio-solution-new-git-experience/


Community Wiki

다음은 .gitignore 파일에 대해 .NET 프로젝트에서 사용하는 것입니다.

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

이것은 기본 제공 Visual Studio 테스터를 사용하는 거의 모든 MS 접근 방식이며 거기에 일부 TFS 바인딩이 있을 수 있는 프로젝트도 있습니다.


Community Wiki

다른 포스터에서 언급했듯이 Visual Studio는 이를 .gitignore의 일부로 생성합니다(최소한 MVC 4의 경우).

 # SQL Server files App_Data/*.mdf App_Data/*.ldf

프로젝트가 솔루션의 하위 폴더일 수 있고 .gitignore 파일이 솔루션 루트에 저장되기 때문에 이것은 실제로 로컬 데이터베이스 파일을 건드리지 않습니다(Git은 projectfolder/App_Data/*.mdf 에서 파일을 봅니다). 이를 설명하기 위해 다음과 같이 해당 줄을 변경했습니다.

 # SQL Server files *App_Data/*.mdf *App_Data/*.ldf

Community Wiki

사용 중인 프로젝트나 언어에 따라 달라야 합니다. 따라서 build, vs folder, sln 파일, bin 폴더 등과 관련된 확장이 포함되어야 합니다. git 무시 파일의 전체 목록을 보려면 이 repo gitignore for Visual Studio를 확인할 수 있습니다.


Community Wiki

일부 프로젝트는 Visual Studio gitignore.io 파일에 *.manifest 를 추가할 수 있습니다.

새 프로젝트의 일부 Visual Studio 프로젝트 속성이 매니페스트 파일을 생성하도록 설정되어 있기 때문입니다.

"Visual Studio의 매니페스트 생성 "을 참조하십시오.

그러나 생성했고 정적(시간이 지나도 변경되지 않음)인 경우 .gitignore 파일에서 제거하는 것이 좋습니다.

이것이 바로 Windows용 Git 과 같은 프로젝트가 수행한 작업입니다(Git 2.24, 2019년 4분기).

Johannes Schindelin( dscho )의 commit aac6ff7 (2019년 9월 5일)을 참조하십시오.
(2019년 9월 30일 커밋 59438be 에서 Junio C gitster -- gitster -- 병합)

.gitignore .manifest 파일 무시 중지

Windows에서는 "매니페스트", 즉 기능 및 요구 사항(예: 최소 또는 최대 Windows 버전)을 설명하는 XML 문서에 링크하여 추가 메타데이터를 실행 파일에 포함할 수 있습니다.
이러한 XML 문서는 .manifest 파일에 저장되어야 합니다.

적어도 일부 Visual Studio 버전은 명시적으로 지정되지 않은 경우 .manifest

그러나 이제 우리에게는 아름다운 .manifest 파일이 있습니다: compat/win32/git.manifest , 따라서 Visual Studio도 자동으로 매니페스트를 생성하지 않으며 Git이 더 이상 .manifest


Community Wiki

출처 : http:www.stackoverflow.com/questions/2143956/gitignore-for-visual-studio-projects-and-solutions

반응형