[英]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.我通过 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.然后我在 VS 2017 中打开它并添加了一些类,之后它们都被标记为“忽略”,带有红色图标和“减号”符号。
When I tried to make a commit, (I want to make commits and push through GitHub App), non of the files where pushed.当我尝试提交时(我想提交并通过 GitHub 应用程序推送),推送的文件没有。
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).所以我做了(在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.尝试在 GitHub 应用程序中提交后,我的所有 .cs 文件再次被标记为“减号”。
What is the reason of it and how to make them not be signed as "ignored"?这是什么原因以及如何使它们不被签名为“忽略”?
They are (most likely) being ignored by .gitignore file.它们(很可能)被 .gitignore 文件忽略。
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/
Not sure if this helps the @Tanya, and here's my partially similar experience.不确定这是否有助于@Tanya,这是我部分相似的经历。
And sadly (as a reflection on my powers of observation) it turned out to be exactly as @goamn had suggested.可悲的是(作为对我观察力的反映)结果与@goamn 所建议的完全一样。
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”.我正在构建一个新的控制台应用程序(非常短的文件列表)来帮助我进行备份活动,我将 VS 项目称为“备份”。
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!):我错过的(第一眼和第二眼)是 .gitignore 中的行(在所有可能位置的“备份和报告文件”中!):
# 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.仅仅从该文件中删除这一行,即使在我已经设置了(在我看来是一个笨蛋)存储库并且在 github 中不起作用之后,也可以直接修复它。 I was able to commit the files with no problem.我能够毫无问题地提交文件。
Hope that helps.希望有帮助。
Say the .gitignore
file has this:假设.gitignore
文件有这个:
*.log
in it.在里面。
Now, a project that's named with a .Log
suffix will not be committed(for example a project called CompanyName.Domain.Service.SubService.Log
)现在,以.Log
后缀命名的项目将不会被提交(例如名为CompanyName.Domain.Service.SubService.Log
的项目)
To add such a project to source control, you'd need to manually add it using:要将这样的项目添加到源代码管理中,您需要使用以下方法手动添加它:
git add <RootFolder>/<CompanyName.Domain.Service.SubService>.Log/* -f
This will force commit the change contrary to the opinion of the .gitignore
file.这将强制提交与.gitignore
文件意见相反的更改。 However, this does not remove the .log
from the .gitignore
file.但是,这不会从.gitignore
文件中删除.log
。 But once the force commit happens, the project is already in source control and will therefore not be subject to the .gitignore
file.但是一旦发生强制提交,该项目已经在源代码控制中,因此将不受.gitignore
文件的约束。 Thereafter, commits to this project will be committed.此后,将提交对该项目的提交。
您需要先添加,确保它们已上演,提交,然后推送
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.