使用git-tfs rcheckin将git提交到TFS更改集的一对一映射

Wil*_*ert 5 git version-control tfs git-tfs

上下文

  • 我们有一个带有发布分支的git存储库.
  • 我们有一个TFS回购(目前为空).

我的任务是将git repo的发布分支镜像到TFS,以便git中的每个提交映射到TFS中的变更集.所有开发人员只提交git和(假设)不知道TFS.

阅读rcheckin文档以及相关问题的答案让我相信rcheckin能够做到这一点.

问题

git中的所有提交都被压缩成一个变更集.

复制顺序:

git tfs clone http://tfs:8080 $/tfsrepo
cd tfsrepo
git remote add github git@github.com:REPO/Repo.git
git fetch github
git merge github/release
git tfs rcheckin
Run Code Online (Sandbox Code Playgroud)

这导致单个签入TFS,其中包含所有提交.

其他尝试解决问题

  • 克隆后,合并来自源(git)repo的第一个提交,rcheckin以创建共享库

    • 这有效,但随后git pull github releasegit-tfs rcheckin导致再次挤压.
  • 对于原始仓库中的前几个提交,我将它们逐个合并到git-tfs共享仓库中并在每个仓库之后进行rcheckin.

    • 对于每次提交,这种方式都有效,TFS中有一个变更集.但是,原始提交消息位于"合并的c02436de4f .."消息下面.
    • 即使使用脚本,对每个变更集也是不现实的.
    • 正如patthoyts所指出的,就TFS而言,这将使我成为改变的提交者.

我的问题

我需要做些什么来保持TFS与git-repo的发布分支保持同步,以便git中的每个提交都有相应的TFS变更集?

附加信息

我确实对这两个repos都有管理控制权,如果有必要,我可以重新设置git repo,这意味着所有后果.我只是不想失去我们已经创建的历史.

Mat*_*rke 3

我认为您看到的是 git-tfs 仅使用沿 HEAD 和 tfs/default 之间最短路径的提交。TFS 的历史记录是更改列表,而 git 的历史记录是图表,并且您遇到了两者之间的阻抗不匹配。要了解 git-tfs 所看到的情况,请git log --graph --oneline --decorate HEAD tfs/default在使用 rcheckin 之前尝试。

如果你想要 1:1::commit:changeset 的东西,试试这个:

git tfs clone http://tfs:8080 $/tfsrepo
cd tfsrepo
git remote add github git@github.com:REPO/Repo.git
git fetch github
git tfs rcheckin github/release
Run Code Online (Sandbox Code Playgroud)

另一种方法是使用cherry-pick 或rebase

git tfs clone http://tfs:8080 $/tfsrepo
cd tfsrepo
git remote add github git@github.com:REPO/Repo.git
git fetch github
git checkout -b about-to-be-rewritten-twice github/release
git rebase tfs/default
git tfs rcheckin
Run Code Online (Sandbox Code Playgroud)

查看rebase 文档,了解更多 rebase 功能的示例。

并且不要git push github about-to-be-rewritten-twice:release