简体   繁体   English

在 Visual Studio 2019 中添加 git 中的所有文件

[英]Adding all files in git in Visual Studio 2019

I have a solution with two projects.我有两个项目的解决方案。 One of them is the main one and I have the 2nd one referenced.其中一个是主要的,我引用了第二个。 However, the 2nd one isn't added to the git changes, and when I push, it only pushes the main project, not the whole solution.但是,第二个没有添加到 git 更改中,当我推送时,它只推送主项目,而不是整个解决方案。 How can I add the whole solution to be tracked by git?如何添加要被 git 跟踪的整个解决方案?

This can happen for a few reasons.这可能有几个原因。 Try the following:尝试以下操作:

  • Check your .gitignore file and make sure you aren't ignoring the second project's folder检查您的.gitignore文件并确保您没有忽略第二个项目的文件夹
  • Check that the second project folder is at the same level or underneath your .git folder检查第二个项目文件夹是否在同一级别或在您的.git文件夹下
  • Check that your .git folder isn't under your first project folder检查您的.git文件夹是否不在您的第一个项目文件夹下

Edit: Okay, based on your comment we know the second project is in the wrong place.编辑:好的,根据您的评论,我们知道第二个项目在错误的地方。 You could move your second project underneath the first one but I wouldn't recommend it.您可以将第二个项目移到第一个项目下方,但我不建议这样做。 The convention with Visual Studio is to have projects in separate folders either at the same level or underneath the.git folder. Visual Studio 的约定是将项目放在同一级别或.git 文件夹下的单独文件夹中。 Depending on the complexity of your project it might just be easier to recreate the correct folder structure somewhere else and create a new repository.根据项目的复杂性,在其他地方重新创建正确的文件夹结构并创建新的存储库可能会更容易。

See the Dapper project on GitHub for an example of the project layout convention.有关项目布局约定的示例,请参阅 GitHub 上的Dapper项目。 The Dapper.sln file is at the same level as the .git folder and projects like Dapper.Contrib and Dapper.EntityFramework are in separate folders underneath that. Dapper.sln 文件与 .git 文件夹处于同一级别, .git和 Dapper.EntityFramework 等项目位于该文件夹下的单独文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM