非常大的 TFS 存储库 — 来自子文件夹的 <git tfs branch>

Very large TFS repo — <git tfs branch> from a subfolder

我将非常感谢有关如何继续手头以下任务的所有建议。我已经相当彻底地阅读了关于 git-tfs clonegit-tfs quick-clonegit-tfs branch 的文档,但仍然无法解决这个问题。

我们的 TFS 代码库非常大(之所以如此,是因为出于令人厌恶的原因,它包含大型 BLOB 等)。然而,它组织得相当好,具有以下结构:

 $/TeamProject/Dev (TERRIBLY LARGE)
  |
  +- $/TeamProject/Dev.EpicX (TERRIBLY LARGE)
  |
  +- $/TeamProject/Dev.EpicY (TERRIBLY LARGE)
  |
  +- $/TeamProject/Dev.EpicZ (TERRIBLY LARGE)

这些 b运行ches 中的每一个都是 "legit" TFS b运行ches(-vs- 只是 b运行ched "folders")。我们可以把Devb运行ch看作是主要的集成b运行ch。这些 b运行ches 包含我们的解决方案和项目,以及其他一些资源(正如我提到的,BLOB 等...)

正如我所说,由于这些 b运行ches 的大小荒谬,我们大多数人甚至都懒得去完整地获取 b运行ch,而只是获取相应的目录或我们正在研究的解决方案。例如,我在 $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectoryDev.EpicY b运行通道。 SolutionDirectory 下的源文件大小更易于管理 (~200MB)。这是我需要创建一个 git 存储库来完成工作的目录,同时享受所有 git 优点(本地 b运行ches 等等),而不会影响我将继续使用 TFS 的同事.

最重要的是:我需要能够通过 "merging" 从相应的 "parent" $/TeamProject/Dev/Foo/Bar/SolutionDirectory 正在不断发展中。


我试过的

第一次尝试:克隆所有 b运行ches

我对项目过去的历史不感兴趣,所以我想使用 git tfs quick-clone

git tfs quick-clone http://tfs-server/Collection $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory . --branches=all

其次是:

git tfs quick-clone http://tfs-server/Collection $/TeamProject/Dev/Foo/Bar/SolutionDirectory . --branches=all

当我这样做时,我没有得到 DevDev.EpicY[ 之间的父子 b运行ching 关系=67=]。例如:

git tfs branch

Git-tfs remote details:
default -> http://tfs-server/Collection $/TeamProject/Dev/Foo/Bar/SolutionDirectory
refs/remotes/tfs/default - 04ddfd8641096a2d02eed4c087423bc0cdeb4ed7 @ 44016

第二次尝试:显式初始化 b运行ches

克隆后。现在我什至得到一个错误:

git tfs branch --init --all

error: The use of the option '--branches=all' to init all the branches is only possible 
when 'git tfs clone' was done from the trunk!!! '$/TeamProject/Dev/Foo/Bar/SolutionDirectory'
is not a TFS branch!

第三次尝试:转到 TFS 并将子文件夹转换为 b运行ches

对于git tfs,TFS 中常规文件夹b运行ches 之间的区别似乎是很重要,所以我去了 TFS 并将 SolutionDirectory 转换为 b运行ch,连同它的层次结构:

 $/TeamProject/Dev/Foo/Bar/SolutionDirectory
  |
  +- $/TeamProject/Dev.EpicX/Foo/Bar/SolutionDirectory
  |
  +- $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory
  |
  +- $/TeamProject/Dev.EpicZ/Foo/Bar/SolutionDirectory

现在当我 运行 git tfs branch --init --all 有了一些进展,但它仍然失败并出现一个奇怪的错误:

git tfs branch --init --all

Tfs branches found:
- $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory
=> Working on TFS branch : $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory
Branches to Initialize successively :
-$/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory (43506)
The name of the local branch will be : Dev.EpicY/Foo/Bar/SolutionDirectory
error: an error occurs when initializing the branch. Branch is ignored and continuing...
=> Working on TFS branch : $/TeamProject/Dev/Foo/Bar/SolutionDirectory
warning: Some Tfs branches could not have been initialized:
- $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory

Please report this case to the git-tfs developers! (report here : https://github.com/git-tfs/git-tfs/issues/461 )
warning: Some Tfs branches could not have been initialized or entirely fetched due to errors:
- $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory
   =>error:error: Couldn't fetch parent branch

clone 命令创建一个新的 git 存储库,从 TFS 源树初始化并获取所有变更集,其中包含 --branches=VALUE 概要。

quick-clone 命令创建一个新的 git 存储库,从 TFS 源代码树中的最后一个变更集(或历史中的特定变更集)初始化,忽略完整的历史记录,这不会包含 --branches=VALUE 个概要。

并且,要使用克隆所有分支的功能,应将与分支对应的所有源代码文件夹都转换为分支。

错误消息指出错误“错误:只能使用选项‘--branches=all’来初始化所有分支 当 'git tfs clone' 是从主干完成的!!!”,在我看来,你只需要使用 Clone 主干(带有依赖分支),检查:https://github.com/git-tfs/git-tfs/blob/master/doc/commands/clone.md

文档有些简洁,但我最终成功地实现了精确 objective 创建一个 git 存储库,其中仅包含 TFS 子目录中必要的历史记录和分支代码库。

原来推荐克隆一个t运行k并不意味着你必须克隆t运行k的整个历史和它的分支,并不是说你被迫留下在顶级 TFS 文件夹中作为分支。

确实,为了git-tfs从TFS中选取一个分支,它必须是一个TFS分支(不仅仅是一个已经被分支的文件夹)。但是你可以暂时将想要的 SolutionDirectory 文件夹转换成 TFS 分支!这是关键。

这是正确的操作顺序:

  1. $/TeamProject/Dev 分支到 $/TeamProject/Dev.EpicY 以开发 ~/Foo/Bar/SolutionDirectory

    时识别 TFS 变更集
    • 假设这个变更集是:43541
  2. 确保$/TeamProject/Dev/Foo/Bar/SolutionDirectory$/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory都是TFS分支

  3. 假设你想在当前目录运行初始化git仓库,执行以下命令:

    PS> git tfs clone --changeset=43541 --branches=all `
        http://tfs-server/Collection $/TeamProject/Dev/Foo/Bar/SolutionDirectory .
    
  4. 显示的输出将显示 TFS 分支是如何沿 ww 方式拾取的以及相应的提交是如何提取的

    Initialized empty Git repository in E:/git-tfs/SolutionDirectory/.git/
    Fetching from TFS remote 'default'...
    1 objects created...
    C43541 = 731d29764d88e424b9d6dfb9a34c107aa4cca9c3
    C43608 = aebc94b96079e73e88ea74ed859eec65440c3b03
    C43609 = 64c03137f555345ec7f24fefc992162e6e082a98
    ...
    C44016 = e1b5c55efa528733ecaa3afba31b05cf1a310cb4
    Tfs branches found:
    - $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory
    => Working on TFS branch : $/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory
    Branches to Initialize successively :
    -$/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory (43506)
    The name of the local branch will be : Dev.EpicY/Foo/Bar/SolutionDirectory
    C43541 = 73589d08398415549fbad191b06c55a272c7ca37
    C43666 = c4bbe9b09138331041cb958cbc8b89f16f7a2902
    C43670 = e7c1e4c787c6c4a745baed46da0eb5d0e3f2fc79
    ...
    C44019 = b2401575dec8347e1debc701073f523aa09e668c
    => Working on TFS branch : $/TeamProject/Dev/Foo/Bar/SolutionDirectory
    
  5. 开心:)