当我保存有更改的文件时,它的状态自动回到未更改/已提交(蓝锁)



当我在visual studio中修改文件(cs/txt)时,它在解决方案资源管理器中的图标从蓝色锁定变为红色v,但一旦我保存文件,图标就会回到蓝色锁定状态,并且在团队资源管理器中没有任何要提交的更改。此问题还会影响对解决方案本身的更改。

是什么可能导致这种行为?

编辑:这是我的。gitignore文件的内容,我没有看到任何异常

## 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

不确定这是否有帮助,但同样的事情发生在我身上。为了解决它,我必须尝试两件事,我相信这两件事可能是导致它的组合,因为单独解决不了它。奇怪的是,在我的解决方案中,3个项目中只有1个发生了这种情况。

  1. 注意到我的。gitattributes和。gitignore文件已经迁移到我的一个项目目录,而不是在解决方案文件夹的根目录(我在我的解决方案中有多个项目)。当我将这两个文件移回存储库的根目录(与.git隐藏目录相同的目录)时。

  2. 编辑项目的文件夹属性。从属性中选择高级,取消选中"允许文件内容索引"-将此应用于所有文件

VS突然意识到变化并允许我提交;即使没有重新启动,这对我来说是第一次修复:)

可能这些是生成的文件,IDE中的一些自动构建器一直覆盖它们。

要弄清楚发生了什么,首先要减少问题空间:退出VS并使用命令行工具。

  1. 当你从命令行运行Git时,你看到文件中的变化了吗?
  2. 如果你用文本编辑器修改了这些文件中的一个,你会在Git中看到变化吗?
  3. 如果你重命名文件.gitignore来隐藏Git,它现在改变了吗?

我刚刚遇到了一个类似的问题:当保存时,visual studio将文件标记为已经提交,这不是真正的情况。提交按钮被禁用,即使我已经输入了一些提交注释。

我这边的问题是。gitignore文件不存在于我的系统中。因此,在创建它之后(使用VS), Team Explorer终于开始像预期的那样工作。

类似问题。尝试使用命令行,发现"。lock";文件已经存在。关闭了所有的应用程序,但文件仍然没有删除,所以我手动删除了它,这解决了问题。

最新更新