将git仓库链接到多个TFS项目 [英] Linking git repository to multiple TFS projects

查看:228
本文介绍了将git仓库链接到多个TFS项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git存储库,需要在其他多个项目之间作为共享库/通用代码进行共享.使用此通用代码的项目都是TFS项目(TFS2013).我能够在TFS中托管git仓库,但无法弄清楚如何将git和TFS仓库链接在一起而不重复.

I have a git repository that needs to be shared across multiple other projects as a shared library/common code. The projects using this common code are all TFS projects (TFS2013). I am able to host the git repo in TFS, but cannot figure out how to link the git and TFS repos together without duplication.

我想要实现的想法与git的子模块相同,其中一个git repo可以是N个其他git repos的子模块:

The idea I am trying to achieve is identical to git's submodules, where one git repo can be a submodule to N other git repos:

- CommonLib/ (git)
    - src/
    - inc/
- Project1/ (git)
    - src/
    - inc/
    - lib/
         -CommonLib (git submodule)
 - Project2/ (git)
    - src/
    - inc/
    - lib/
         -CommonLib (git submodule)

但是当项目是TFS存储库时,我想这样做:

But I would like to do this when the projects are TFS repositories:

- CommonLib/ (git)
    - src/
    - inc/
- Project1/ (TFS)
    - src/
    - inc/
    - lib/
         -CommonLib (?? How to link ??)
 - Project2/ (TFS)
    - src/
    - inc/
    - lib/
         -CommonLib (?? How to link ??)

这可能吗?

我想到的一个解决方案是将CommonLib存储库克隆到项目的每个lib/目录中,并适当地设置上游远程服务器.但是然后我必须将git repo检入到TFS repo中,这对我来说似乎是错误的.

One solution I came up with is just to clone the CommonLib repo into each of the project's lib/ directory and set the upstream remote appropriately. But then I have to check in the git repo into the TFS repo and that seems incorrectly to me.

我希望在Project2中对CommonLib进行源代码更改的开发人员能够在签入TFS时自动将其对git repo的更改签入.类似于使用git子模块的方式,他们可以在父级的一个git提交中提交项目更改(父级)和子模块(子级)更改.

I would like a developer who makes a source change in CommonLib within Project2, to be able to check in their changes to the git repo automatically when they checkin to TFS. Similar to how one would use a git submodule, where they can commit both the project changes (parent) and the submodule (child) changes in a single git commit from the parent.

推荐答案

是的,有可能.您可以通过 git命令行(例如 git bash ),因为TFS IDE(可视化Studio)无法很好地显示git子模块,但

Yes, it’s possible. You can add submodule for a TFS git repo by git command Line (such as git bash) since TFS IDE (visual studio) can’t well show git submodule but it will improved in the near future.

为TFS git repo Project1添加子模块的命令(类似于Project2),如下所示:

The commands to add submodule for TFS git repo Project1 (similar with Project2) as below:

git clone http://account:8080/tfs/DefaultCollection/_git/Project1
cd Project1
git submodule add http://account:8080/tfs/DefaultCollection/_git/CommonLib
git push

如果CommonLib已更新,并且可以通过git submodule update --remote更新Project1中的子模块.

If the CommonLib is updated and you can update the submodule in Project1 by git submodule update --remote.

子模块中的文件可以在本地存储库中查看.您只会在TFS git repo上找到子模块的最新提交ID.

Files in submodule can view in local repo. You will only find the latest commit id of submodule on TFS git repo.

这篇关于将git仓库链接到多个TFS项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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