2

I'm using two computers with Visual Studio Ultimate 2012 and the Github extension for it. There are multiple solutions in the repository. Sometimes after commiting, the sln, csproj, App.config and AssemblyInfo.cs files are missing in the repository.

I found them with the Git Gui program under "Unstaged Changes" and could add them. I have to do this every time I add a new solution.

As far as I can see it, the .gitignore file is not responsible for this.

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

What is the reason for this behaviour and how can it be fixed?

Edit for additional information:

I'm only working on the master, there are no branches.

I tried it again. Files untracked were:

$ git status -u 
On branch master 
Your branch is up-to-date with 'origin/master'.  
Untracked files:  
(use "git add <file>..." to include in what will be committed)  

007 10001st prime/10001st prime/10001st prime.sln  
007 10001st prime/10001st prime/10001st prime/10001st prime.csproj  
007 10001st prime/10001st prime/10001st prime/App.config  
007 10001st prime/10001st prime/10001st prime/Properties /AssemblyInfo.cs   

The files ignored were:

$ git status --ignored
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        007 10001st prime/10001st prime/10001st prime.sln
        007 10001st prime/10001st prime/10001st prime/10001st prime.csproj
        007 10001st prime/10001st prime/10001st prime/App.config
        007 10001st prime/10001st prime/10001st prime/Properties/

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

        005 Smallest multiple/Smallest multiple/Smallest multiple/Smallest multiple.v11.suo
        005 Smallest multiple/Smallest multiple/Smallest multiple/bin/
        005 Smallest multiple/Smallest multiple/Smallest multiple/obj/
        006 Sum square difference/Sum square difference/Sum square difference.v11.suo
        006 Sum square difference/Sum square difference/Sum square difference/bin/
        006 Sum square difference/Sum square difference/Sum square difference/obj/
        007 10001st prime/10001st prime/10001st prime.v11.suo
        007 10001st prime/10001st prime/10001st prime/bin/
        007 10001st prime/10001st prime/10001st prime/obj/

nothing added to commit but untracked files present (use "git add" to track)

It seems that they are not ignored, just untracked.

Antitheos
  • 135
  • 9
  • 1
    That might be a bug from ligbit2 used in VC2012, while VC2015 has shifted to git (http://stackoverflow.com/a/40059664/6309) – VonC Dec 23 '16 at 13:13

1 Answers1

3

To really be sure those files are not ignored, double-check (when you see that case again) with

git check-ignore -v -- /path/to/missing/file.sln

That way, you will be sure no .gitignore is responsible.

Make sure you did not just switch from branches (as in this case)


Guy Lowe mentions in the comments:

I had this issue with new .cs files with the line *.user in my gitignore

It was because I had the word user in my folder structure.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks.:) I'll try it when it happens again and update it. I have no branches. I only work on the master branch. – Antitheos Dec 23 '16 at 09:18
  • 1
    Yes, I had seen your previous edit, hence my comment. – VonC Dec 23 '16 at 14:06
  • I had this issue with new .cs files with the line *.user in my gitignore. Not sure why. – Guy Lowe Aug 11 '20 at 01:11
  • @GuyLowe Strange. Do you mean `git check-ignore -v` mention a `*.user` ignore rule for `.cs` files? – VonC Aug 11 '20 at 06:08
  • It was because I had the word user in my folder structure. I can't be the only one to have seen this but obviously the only one to mention it on SO. – Guy Lowe Aug 12 '20 at 01:36
  • @GuyLowe Good point. I have included your comment in the answer for more visibility. – VonC Aug 12 '20 at 06:33