2

When I modify a file (cs/txt) in visual studio, its icon in solution explorer goes from blue lock to red v, but as soon as I save the file, the icon goes back to blue lock and there aren't ever any changes to commit in Team Explorer. This issue also affects changes to the solution itself.

What could possibly be causing this behavior?

Edit: This is the content of my .gitignore file, I don't see anything unusual

## 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
Luis Ferrao
  • 1,463
  • 2
  • 15
  • 30

4 Answers4

1

Not sure if this helps but the same thing happened to me. To solve it, I had to try two things which I believe may be the combination which causes it because individually it did not solve it. What was odd was that it happened to only 1 of 3 projects in my solution.

  1. noticed that my .gitattributes and .gitignore files had migrated to one of my project directories instead of being at the root of the solution folder (I had multiple projects in my solution). When I moved the two files back to the root of the repository (same directory as the .git hidden directory).

  2. edit the folder properties for the project. Select Advanced from the Attributes and uncheck the "Allow files contents indexed" - apply this to all files

VS suddenly recognized the change and allowed me to commit; even with out restarting which is a first for a fix for me :)

Hope this helps.

Dave Friedel
  • 1,028
  • 1
  • 14
  • 20
0

Maybe these are generated files and some automatic builder in the IDE overwrites them all the time.

To figure out what is going on, first reduce the problem space: Exit VS and use command line tools.

  1. Do you see a change in the file when you run Git from the command line?
  2. If you change one of these files with a text editor, do you see a change in Git?
  3. If you rename the file .gitignore to hide it from Git, does it change now?
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I will test these things, but I can already discard the assumption that these files are overwritten, as it happens to all the files in the solution, including the solution itself, and nothing is overwriting my changes as they are still pretty much there. – Luis Ferrao Jul 31 '14 at 12:10
  • Git doesn't show a status for files which are ignored. I'm not sure what happens when you add and commit a file which is mentioned in .gitignore; but you can try that easily with a new tiny demo git repo. So the next step is to run Git from the command line to take as many lines of code out of the bug as possible. – Aaron Digulla Jul 31 '14 at 12:13
0

I just had a similar issue: when saving, visual studio was marking the file as being already committed, which was not really the case. The commit button was disabled, even if I already typed in some commit comment.

The problem on my side was that the file .gitignore was not present on my system. So, after creating it (using VS) Team Explorer finally started to work as expected.

Cosmin
  • 1
0

Similar issue. Tried using the command line and found out the ".lock" file already exists. Closed all applications but the file still was not deleted so I deleted it manually, which solved the issue.