Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Visual Studio mark my added .cs files as "ignored"?

I cloned an existing but almost empty project on my local machine through GitHub for Windows. Then I opened it in VS 2017 and added a few classes after what they all became marked up as "ignored" with red icons with "minus" sign on them.

When I tried to make a commit, (I want to make commits and push through GitHub App), non of the files where pushed.

Then I tried right-clicking on the files and adding them to source control. Then "minus" signs became "+".

I also thought maybe the problem lies in the fact that I didn't stage them. So I did (in VS). But I still cannot push these files. After an attempt to make a commit in GitHub app all my .cs files again become marked up with "minus" sign.

What is the reason of it and how to make them not be signed as "ignored"?

like image 589
Tanya K. Avatar asked Oct 18 '17 19:10

Tanya K.


2 Answers

They are (most likely) being ignored by .gitignore file.

If you can't see anything obvious (check substrings of the file name as well as extension), then look for these and remove them:

/* !/content/

like image 77
goamn Avatar answered Oct 11 '22 07:10

goamn


Not sure if this helps the @Tanya, and here's my partially similar experience.

And sadly (as a reflection on my powers of observation) it turned out to be exactly as @goamn had suggested.

I was building a new console app (very short list of files) to help me do a backup activity, and I had called the VS project “backup”.

What I missed (at first and second glance) was that in the .gitignore was the line (in the “Backup & report files” of all likely places!):

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
Backup*

Merely removing this line from that file, even after I had (what appeared to me to be a horked) repository already set up and non functional in github, fixed it right up. I was able to commit the files with no problem.

Hope that helps.

like image 20
Kenneth Ray Avatar answered Oct 11 '22 08:10

Kenneth Ray