Antitheos
Antitheos

Reputation: 135

Why is GitHub sometimes ignoring my Visual Studio files?

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.

Upvotes: 2

Views: 1574

Answers (1)

VonC
VonC

Reputation: 1323773

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.

Upvotes: 3

Related Questions