我将非常感谢有关如何继续执行以下任务的所有建议。我已经对git-tfs clone
,git-tfs quick-clone
和git-tfs branch
上的文档进行了相当详尽的阅读,但仍无法解决此问题。
我们的TFS代码库是可怕的(这是因为由于可恶的原因它包含大型BLOB等)。然而,它组织得很好,并具有以下结构:
$/TeamProject/Dev (TERRIBLY LARGE)
|
+- $/TeamProject/Dev.EpicX (TERRIBLY LARGE)
|
+- $/TeamProject/Dev.EpicY (TERRIBLY LARGE)
|
+- $/TeamProject/Dev.EpicZ (TERRIBLY LARGE)
这些分支中的每一个都是"合法的" TFS分支(-vs-刚刚分支"文件夹")。我们可以将 Dev 分支视为主要的集成分支。这些分支包含我们的解决方案和项目,以及其他一些资源(正如我所提到的,BLOB等......)
正如我所说,由于这些分支的荒谬,我们大多数人甚至都不打算整个分支,而只是我们正在处理的相应目录或解决方案。例如,我正在 Dev.EpicY 分支中的 $ / TeamProject / Dev.EpicY / Foo / Bar / SolutionDirectory 工作。 SolutionDirectory 下的源代码大小更易于管理(~200MB)。这是我需要创建一个git
repo来完成工作,同时享受所有git
良好(本地分支等)而不影响将继续使用TFS的同事的目录。
最重要的是:我需要能够通过"合并"进行前向整合。来自相应的父母" $ / TeamProject / Dev / Foo / Bar / SolutionDirectory 正在不断发展中。
我对项目的过去历史不感兴趣,所以我想使用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
当我这样做时,我没有得到 Dev 和 Dev.EpicY 之间的亲子分支关系。例如:
git tfs branch
Git-tfs remote details:
default -> http://tfs-server/Collection $/TeamProject/Dev/Foo/Bar/SolutionDirectory
refs/remotes/tfs/default - 04ddfd8641096a2d02eed4c087423bc0cdeb4ed7 @ 44016
克隆后。现在我甚至得到一个错误:
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!
对于git tfs
来说,TFS中常规文件夹与分支之间的区别很重要,所以我去了TFS并转换了 SolutionDirectory < / strong>到分支机构,以及它的层次结构:
$/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
答案 0 :(得分:2)
文档有点简洁,但我终于成功实现了只使用TFS子目录中必要的历史记录和分支代码库创建git repo的确切目标。
事实证明,克隆中继的建议并不意味着你必须克隆中继及其分支的整个历史记录,而不是你被迫作为分支留在顶级TFS文件夹中。
实际上,为了让git-tfs
从TFS中获取分支,它必须是 TFS分支(而不仅仅是已经分支的文件夹)。但您可以暂时将所需的SolutionDirectory
文件夹转换为TFS分支!这是关键。
这是正确的行动顺序:
确定$/TeamProject/Dev
分支到$/TeamProject/Dev.EpicY
以开发~/Foo/Bar/SolutionDirectory
时的TFS变更集
确保$/TeamProject/Dev/Foo/Bar/SolutionDirectory
和$/TeamProject/Dev.EpicY/Foo/Bar/SolutionDirectory
TFS分支
假设您要在当前目录中初始化git存储库,请运行以下命令:
PS> git tfs clone --changeset=43541 --branches=all `
http://tfs-server/Collection $/TeamProject/Dev/Foo/Bar/SolutionDirectory .
显示的输出将显示如何沿着路径拾取TFS分支并获取相应的提交
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
快乐:)
答案 1 :(得分:1)
clone命令创建一个新的git存储库,从TFS源代码树初始化并获取所有包含--branches=VALUE
概要的变更集。
quick-clone命令创建一个新的git存储库,从TFS源代码树中的最后一个变更集(或历史记录中的特定变更集)初始化,忽略不包含--branches=VALUE
的完整历史记录概要
并且,要使用功能克隆所有分支,所有与分支对应的源代码文件夹都应转换为分支。
错误消息指出错误“错误:只能使用选项'--branches = all'来初始化所有分支 当'git tfs clone'从主干完成!!!“,在我看来,你只需要克隆主干(带有依赖分支),检查:https://github.com/git-tfs/git-tfs/blob/master/doc/commands/clone.md