Git 和 tfs:我可以只让中央存储库与 tfs 通信吗?
我想将我的团队从使用 TFS 进行版本控制转移到 git。
有什么理由我不应该执行以下操作:
- 使用 git-tfs 创建中央 git 存储库
- 让每个开发人员克隆中央存储库,从中提取并推送到它
- 然后仅从中央存储库更新 tfs?
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能很危险,因为 TFS 有一个中央存储库,其中包含所有内容。
生成的 git 存储库最终可能会成为一个巨大(不容易克隆),
我建议创建多个
git-tfs
以便创建几个较小的< /em> Git 存储库。The can be dangerous, as TFS has a central repository with everything in it.
The resulting git repo can end up being a huge one (not easy to clone around)
I would recommend making several
git-tfs
in order to create several smaller Git repos.由于 Git 和 TFS(git-tfs)中的交互并不完美(因为 Git 的一个主要特点是一旦创建就无法修改提交,并且 git-tfs 不起作用)与裸存储库),将中央 Git 存储库放在 TFS 前面并不简单...
我想您所有的团队都会使用这个工作流,否则,您可能会停止考虑这样做的想法(由于合并冲突,您将遇到到管理)...
因为 git-tfs 不适用于裸存储库,所以实际上您最终会得到 2 个应该同步的 git 存储库。第一个是你推送的(裸露的),第二个是与 TFS 交互的(不是你使用 git-tfs 的裸露的)。
然后,你有 2 个选择:
a) 即使您有多个 git 提交,您也接受在 TFS 上只进行一次提交(使用 git-tfs 'checkin' 命令)
b) 你想要复制 TFS 中的每个 git 提交(使用 git-tfs 'rcheckin' commit)
第一种情况 a) 并不是更好,但使用一些 scipts 和 git hooks 更容易解决,因为总是只有新的 git 提交在 2 个存储库之间同步。
对我来说,第二种情况 b) 是唯一可以接受的,但更难解决,因为当您使用 git-tfs 'rcheckin' 命令同步 git 存储库时,对于每个 git 提交,都会创建一个新的提交,并且同步脚本将写起来要困难得多(我什至不知道是否可以解决所有合并冲突)。我开始编写这些脚本,但停止了,因为它不值得付出努力(特别是现在 Visual Studio 2012 解决了每次重新加载解决方案文件时的重新加载问题)。如果您想这样做,下面帖子中的脚本是一个很好的起点......
总之,我认为这样做不值得。你可以找到一个使用 git-tfs 的本地工作流程,这非常简单,不需要 git 中央存储库...
但是如果你仍然想拥有一个 Git 中央存储库,你可以查看这篇文章 ( http://sparethought.wordpress.com/2012/08/23/my-environment-for-day-to-day-work-with-git-tfs/ )的混合方式(提交到 TFS 并从 git 获取)似乎有效。
Due to the fact that the interaction in Git and TFS, git-tfs, is not perfect (due to the fact that a main caracteristic of Git is that you can't modifiy a commit once created and that git-tfs doesn't work with bare repositories), putting a central Git repository in front of TFS is not straight forward...
I imagine all your team will use this worflow otherwise, you could stop thinking to the idea to do this (due to merge conflict you will have to manage)...
Because git-tfs doesn't work with a bare repository, you will end up with, in fact 2 git repositories that you should sync. The 1st one where you push ( a bare one) and the 2nd which interact with TFS (not bare where you use git-tfs).
Then, you've got 2 options :
a) you accept to have only one commit on TFS even if you have multiple git commit (use git-tfs 'checkin' command)
b) you want to replicate each git commit in TFS (use git-tfs 'rcheckin' commit)
The first case a) is not the better but is the easier to solve with some scipts and git hooks because there is only always new git commit to sync between the 2 repositories.
The 2nd case b) is, for me, the only acceptable but is much more harder to solve because when you sync git repository with git-tfs 'rcheckin' command, for each git commit, a new one is created and the sync script will be much harder to write (I don't even know if all the merge conflict could be resolved). I begun to do write these script but stoped because it doesn't worth the effort (especially now that Visual Studio 2012 resolve the reload problem where every time the solution files was reloaded). If you want to do that, the scripts in the post below are a good step from where to begin...
In conclusion, I think it doesn't worth the work to do that. You could find a local workflow with git-tfs which is quite easy and don't need a git central repository...
But if you still want to have a Git central repository, you could check this post ( http://sparethought.wordpress.com/2012/08/23/my-environment-for-day-to-day-work-with-git-tfs/ ) of an hybrid way (commit to TFS and fetch from git) that seems works.
Team Foundation Server 2013 现在支持 Git 作为团队项目的源代码控制存储库,并且 Visual Studio Tools for Git 提供嵌入在 Visual Studio 中的 Git 访问 (2012 年插件,包装盒中附带2013)。
Team Foundation Server 2013 now supports Git as source control repository for a Team Project and the Visual Studio Tools for Git provide Git access embedded in Visual Studio (add-in for 2012, ships in the box with 2013).