在 Visual Studio 中使用 Git 的最佳实践?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1426467/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:50:47  来源:igfitidea点击:

Best Practices Using Git with Visual Studio?

.netvisual-studiogit

提问by Stuart Ellis

I'm considering migrating from Subversion to Git at work, and would like to get opinions about the best way to set up Git on Windows, and any problems that might arise from the combination of Visual Studio and Git.

我正在考虑在工作中从 Subversion 迁移到 Git,并希望获得有关在 Windows 上设置 Git 的最佳方式的意见,以及 Visual Studio 和 Git 组合可能出现的任何问题。

The current setup is TortoiseSVN, with Visual Studio 2008 and AnkhSVN for .NET applications. The replacement would probably be Git Extensions.

当前设置是 TortoiseSVN,带有用于 .NET 应用程序的 Visual Studio 2008 和 AnkhSVN。替代品可能是Git Extensions

Advice on repository layouts would be particularly appreciated. All of our solutions use multiple projects, and we now have a number of custom assemblies that we will need to share between applications. The current layout of our Subversion repositories definitely isn't optimal.

特别感谢有关存储库布局的建议。我们所有的解决方案都使用多个项目,我们现在有许多需要在应用程序之间共享的自定义程序集。我们 Subversion 存储库的当前布局绝对不是最佳的。

UPDATE: I've now migrated to Git using Git Extensions, and it's working very well. Shared code and assets live in separate repositories and are used as submodules. I found submodules slightly confusing when I started, and this postwas very helpful.

更新:我现在已经使用 Git 扩展迁移到 Git,它运行良好。共享代码和资产存在于单独的存储库中并用作子模块。当我开始时,我发现子模块有点令人困惑,这篇文章非常有帮助。

采纳答案by Jon Spokes

We have a solution containing 9 projects & we're using git extensions (having come from the svn stack).

我们有一个包含 9 个项目的解决方案,我们正在使用 git 扩展(来自 svn 堆栈)。

Three of the projects are shared with other solutions and we've used sub modules to reference them.

其中三个项目与其他解决方案共享,我们使用子模块来引用它们。

This just about works but the interface to it is very confusing. Going forward we're thinking of removing the sub modules and just referencing the dlls instead.

这几乎有效,但它的界面非常混乱。展望未来,我们正在考虑删除子模块而只引用 dll。

回答by VonC

The main Git installer for Windows is msysgit (SO question).
TortoiseGitis also a nice Windows integration (on top of msysgit).

Windows 的主要 Git 安装程序是msysgit (SO question)
TortoiseGit也是一个很好的 Windows 集成(在 msysgit 之上)。

You need to be aware of Git limits, particularly in term of Git repository (do not try to stuff every projects into one repo, unless you are building a "system", i.e. something which can only run with allits parts/components.)

您需要了解Git 限制,尤其是在 Git 存储库方面(不要尝试将每个项目都塞进一个存储库,除非您正在构建一个“系统”,即只能与其所有部件/组件一起运行的东西。)

External code dependencies are best represented with submodules.
Same thing for vendor branches.

外部代码依赖关系最好用子模块表示。
对于同样的事情提供商分支



Note also that, in addition of GitExtension, you now can define Git projects in TFS (Q1 2013):
See "How can I push my existing Git repository to Team Foundation Service": starting VS2012.2, yo have git commands directly from your IDE.

另请注意,除了 GitExtension,您现在还可以在 TFS(2013 年第一季度)中定义 Git 项目:
请参阅“如何将我现有的 Git 存储库推送到 Team Foundation Service”:从 VS2012.2 开始,您可以直接从您的集成开发环境。

回答by mkato

I'm using msysgit, it's pretty nice =)

我正在使用msysgit,它非常好 =)

For the Git Extensions, I don't like much, since I'm more comfortable with command line commands... But the "File History" feature of Git Extensions is awesome

对于 Git 扩展,我不太喜欢,因为我更习惯使用命令行命令……但是 Git 扩展的“文件历史记录”功能很棒