use*_*546 41 windows git directory gitignore visual-studio-2015
这个在Windows上运行Git的几个团队成员.我们已经在.gitignore中尝试了各种显式和通配符条目,但隐藏的.vs /文件夹中的项目作为Visual Studio 2015 RC的一部分不断提交.由于这些是开发人员的个人设置,因此它们显然总是不同的并且显示在git diff中.是否有任何黑客可以忽略回购中顶级.vs /文件夹中的所有内容?
Bra*_*ung 41
第1步:将以下内容添加到文件.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/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# 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
# 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: 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/
# 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/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# 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/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# 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
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.imlRun Code Online (Sandbox Code Playgroud)
第2步:确保上述操作生效
如果问题仍然存在,那是因为.gitignore中的设置只能忽略最初未跟踪的文件.如果某些文件已包含在版本控制系统中,则修改.gitignore无效.要完全解决此问题,您需要在存储库根文件夹中打开运行以下命令的Git Bash.
$ git rm -r --cached .
$ git add .
$ git commit -m 'Update .gitignore'Run Code Online (Sandbox Code Playgroud)
当然,您也可以使用Visual Studio的Package Manager Console来执行第2步中的操作.
然后问题就会彻底解决.
Dav*_*sch 32
如果它们显示在a中git diff,则表示文件已被跟踪,而.gitignore仅影响未跟踪的文件.您将需要从源控件中删除文件git rm --cached,然后 .gitignore将影响它们.
请注意,当您执行此操作时,其他开发人员将在下一次执行文件时将其本地删除git pull.所以在这之前,他们可能想要备份这些文件.
Cha*_*yah 13
在我们的例子中,.vs当我初始化存储库时,该目录已添加到源代码管理中.因此,该行.gitignore:
/.vs
Run Code Online (Sandbox Code Playgroud)
在我删除目录并检查更改之前没有做任何事情(类似于TPoschel上面所说的,但区别在于检查已删除的目录是什么修复它,因为我已经检查了.gitignore文件).
它对我来说是这样工作的:打开 gitignore 文件并将以下内容添加到列表中:
.vs/
这个答案与上面的类似,但是详细说明了有效.gitignore 文件就位时的实际步骤,但项目已签入分支并且它们出现在原始存储库中。
.vs已签入目录,请验证当前分支中是否没有从该目录暂存任何内容。如果是这样,请取消暂存它们。.vs.git rm --cached -r .vs.