Git Repo 应该在 Visual Studio 中的解决方案级别还是项目级别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1094431/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Should Git Repo's be at the Solution Level or Project Level in Visual Studio
提问by cmaduro
If I have a C# solution with multiple projects in it, what would be better, to have the Git repo created in the solution folder, or in each individual project folder? Multiple developers will be working on the projects. What are your experiences with this?
如果我有一个包含多个项目的 C# 解决方案,那么在解决方案文件夹或每个单独的项目文件夹中创建 Git 存储库会更好吗?多个开发人员将致力于这些项目。您对此有何经验?
采纳答案by bouvard
I use several (sometimes over-lapping) solutions to contain a collection of related independent applications and shared libraries. As others have mentioned, you really don't want to have a single Git repository containing the source for multiple, independent projects as it makes it much too difficult to track isolated changes.
我使用了几个(有时是重叠的)解决方案来包含一组相关的独立应用程序和共享库。正如其他人所提到的,您真的不希望有一个包含多个独立项目源的单个 Git 存储库,因为这使得跟踪孤立的更改变得非常困难。
So, if your solution is structured as mine is then you will definitely want individual Git repositories for each project. This has worked well for me for ten to twelve applications and doesn't create as much maintenance overhead as you might think.
因此,如果您的解决方案的结构与我的一样,那么您肯定希望每个项目都有单独的 Git 存储库。对于 10 到 12 个应用程序,这对我来说效果很好,并且不会像您想象的那样产生那么多的维护开销。
If your solution is truly monolithic (and your sure you want it that way forever and ever), then it probably makes sense to only have a single repository.
如果您的解决方案确实是单一的(并且您确定您希望永远这样),那么只有一个存储库可能是有意义的。
回答by CB Bailey
It depends. git
repositories are most suited to containing a single configuration itemwith it's own independent lifecycle. If your projects have there own release cycle and are shared between multiple solutions then it might make sense to have them in their own repositories. Usually, though, it is the solution that represents a configuration itemwith all the constituent projects forming part of the same build. In this case a single git
repository at the solution level makes more sense.
这取决于。git
存储库最适合包含具有自己独立生命周期的单个配置项。如果您的项目有自己的发布周期并且在多个解决方案之间共享,那么将它们放在自己的存储库中可能是有意义的。但是,通常情况下,它是表示配置项的解决方案,其中所有组成项目构成同一构建的一部分。在这种情况下git
,解决方案级别的单个存储库更有意义。
回答by Bryan Alves
git submodule is probably worth consideration here. Each project gets it's own repo, the solution gets a repo, and the projects are submodules.
git submodule 在这里可能值得考虑。每个项目都有自己的仓库,解决方案有一个仓库,项目是子模块。
回答by Albic
I assume that your solution represents some kind of a product while the projects are just a part of the product.
我假设您的解决方案代表某种产品,而项目只是产品的一部分。
In this situation I would create the repository on the solution level. This way it is a lot easier to build the whole product at once, especially if the projects depend on each other.
在这种情况下,我会在解决方案级别创建存储库。通过这种方式,一次构建整个产品会容易得多,尤其是在项目相互依赖的情况下。
回答by EricBDev
Some though and 3 solutions on the subject can be read on that blog: http://blogs.atlassian.com/2014/04/git-project-dependencies/
可以在该博客上阅读有关该主题的一些和 3 个解决方案:http: //blogs.atlassian.com/2014/04/git-project-dependencies/
- package management tool, i.e. nuget in VS, so using reference to a package/compiled module
- git submodule (only with command line in VS?)
- other build and cross-stack dependency tools
- 包管理工具,即 VS 中的 nuget,因此使用对包/编译模块的引用
- git 子模块(仅在 VS 中使用命令行?)
- 其他构建和跨堆栈依赖工具
Another solution is just to add a project from the other repo and let it out of the current repo, and latter use the Team Explorer to commit its changes.
另一种解决方案是从另一个 repo 添加一个项目并将其从当前 repo 中删除,然后使用 Team Explorer 提交其更改。