简体   繁体   English

克隆git-tfs中央存储库,并隐藏TFS

[英]cloning a git-tfs central repo, and hiding TFS

I have a code repository in TFS (Microsoft Team Foundation Server). 我在TFS(Microsoft Team Foundation Server)中有一个代码存储库。 I can use git-tfs to convert this to a git repository. 我可以使用git-tfs将其转换为git存储库。

But what I want to do is set up one central git repo that pushes to TFS, and have all developers clone that git repo and not be able to push to TFS. 但是我要做的是设置一个推送到TFS的中央git repo,并让所有开发人员克隆该git repo 而不能够推送到TFS。 As far as anyone "downstream" from the central repo., I don't want any indication there's a TFS repo at all. 至于从中央存储库“下游”的任何人,我都不希望有任何迹象表明存在TFS存储库。

Since the TFS server information is included in the repo produced by git-tfs, how can I do this? 由于TFS服务器信息包含在git-tfs生成的存储库中,我该怎么做?

There's several problems need to be solved for this to work. 要使其正常工作,需要解决几个问题。 Most prominent is mapping from git users to TFS credentials that will be used when checking in changes back to TFS. 最突出的是从git用户到TFS凭证的映射,这些值将在将更改签回到TFS时使用。

And other troublesome thing is possible conflict with other TFS users (ie if someone decides to push things to TFS directly). 其他麻烦的事情可能是与其他TFS用户的冲突(即,如果有人决定将事情直接推送到TFS)。

That is why it wasn't developed as part of git-tfs I believe (at least that is why I didn't added this feature several months ago). 这就是为什么我认为它不是作为git-tfs的一部分开发的(至少这就是为什么几个月前我没有添加此功能的原因)。

If you're ok with having TFS login/password pairs in plain text file, and you can ensure conflict-free workflow (eg to prohibit checkins to TFS in any other way except through your git central repository) - you can implement what you need with commit hooks or even with simple scheduler (so pushing will be not immediate, but deferred and asynchronous, thus speeding up pushing to git central repository significantly). 如果可以在纯文本文件中使用TFS登录/密码对,并且可以确保无冲突的工作流(例如,通过git中央存储库禁止以其他任何方式签入TFS),则可以实现所需的操作使用提交钩子甚至使用简单的调度程序(因此推送不会是立即的,而是延迟的和异步的,从而大大加快了推送到git中央存储库的速度)。

Actual script should be pretty straightforward, but nobody bothered to write one yet (at least I don't know of such thing). 实际的脚本应该很简单,但是没有人愿意编写一个脚本(至少我不知道这样的事情)。

Firstly, strip off TFS metadata from your commits using the --no-metadata flag. 首先,使用--no-metadata标志从提交中删除TFS元--no-metadata Then use the --authors="path-to-authors.txt" flag to map your TFS users to current. 然后使用--authors="path-to-authors.txt"标志将您的TFS用户映射到当前用户。

git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1 --authors="c:\project1\authors.txt" --no-metadata

In your authors.txt, map your users TFS id to their email like this: 在您的authors.txt中,将用户的TFS ID映射到他们的电子邮件,如下所示:

TFSDOMAIN\peter.pan = Peter Pan <peter.pan@disney.com>

After cloning the repo, run git tfs bootstrap and remove the TFS configuration in your .git/config file. 克隆存储库后,运行git tfs bootstrap并删除.git/config文件中的TFS配置。 You now should not be able checkin to TFS but still be able to share the repo among your developers. 现在,您不应该能够签到TFS,但仍然能够在开发人员之间共享存储库。

More details on git tfs clone https://github.com/git-tfs/git-tfs/blob/master/doc/commands/clone.md 有关git tfs clone更多详细信息https://github.com/git-tfs/git-tfs/blob/master/doc/commands/clone.md

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

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