在Visual Studio中使用git子模块的工作流程 [英] Workflow for using git submodules in Visual Studio

查看:719
本文介绍了在Visual Studio中使用git子模块的工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一些解决方案中共享一些共享代码.大多数示例都使用命令行,但是我想使用Visual Studio 2013(和/或TortoiseGit)来实现?

I have some shared code I want to share among a number of solutions. Most examples use the command line, but I want to do it using Visual Studio 2013 (and/or TortoiseGit)?

- SolutionShared
  - .git
  - Project1Shared
  - Project2Shared
- Solution1
  - .git
  - ProjectFoo
  - ProjectBar
  - [SolutionShared]
    - [Project1Shared]
    - [Project2Shared]
- Solution2
  - .git
  - ProjectBaz
  - ProjectQux
  - [SolutionShared]
    - [Project1Shared]
    - [Project2Shared]

我要做的是创建一个新的解决方案SolutionShared,在其中添加所有共享代码,并将其添加到其自己的git repo中.然后,我使用TortoiseGit(因为我不知道如何在Visual Studio中进行操作)将共享存储库作为git子模块添加到Solution1Solution2.

What I did was to create a new solution SolutionShared, add all my shared code there, and add it to its own git repo. I then used TortoiseGit (as I couldn't figure out how to do it Visual Studio) to add that shared repo as a git submodule to Solution1 and Solution2.

1.我在Visual Studio中做什么?
我的两个解决方案现在都有一个SolutionShared目录.我是否只需在Visual Studio中添加其两个子项目(Project1SharedProject2Shared)?

1. What do I do in Visual Studio?
My two solutions now have a SolutionShared directory. Do I simply add its two child projects (Project1Shared and Project2Shared) in Visual Studio?

2.如何在非共享项目中更改共享代码
如果我在一个非共享解决方案中,并且对子模块中的内容进行了更改,我该如何提交并将其推回共享解决方案的存储库(SolutionShared),以便引用该解决方案的所有解决方案都可以使用它?

2. How do I make changes to the shared code from within the non-shared projects
If I'm in one of the non-shared solutions and make a change to something in the submodule, how do I commit and push it back to the shared solution's repo (SolutionShared) so that it's available to all solutions that reference it?

推荐答案

经过大量实验...

在VS中,将子项目中的共享项目添加到解决方案中.就版本控制而言,它们似乎位于父解决方案之外.

In VS, add the shared projects from the submodule to the solution. They seem to live "outside" the parent solution as far as versioning.

如果您对子模块的项目进行编辑,则它们是本地的.它们需要提交并推送到源存储库,然后您需要在此处合并它们.如果您在源代码上进行更改,则需要将它们手动拉到解决方案的git子模块中.

If you make an edit to the submodule's projects, they are local. They need to be committed and pushed to the source repo, and then you need to merge them there. If you make changes at the source, you need to pull them manually into your solution's git submodule.

问题是VS并没有为您做任何事情,因此您需要使用TortoiseGit或命令行之类的东西.

Problem is VS doesn't do any of this for you, so you need to use something like TortoiseGit or the command line.

这篇关于在Visual Studio中使用git子模块的工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆