git的一对一映射使用git-tfs rcheckin提交给TFS变更集 [英] One-to-one mapping of git commits to TFS changesets using git-tfs rcheckin

查看:140
本文介绍了git的一对一映射使用git-tfs rcheckin提交给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

这会导致一次签入包含所有提交的TFS。

解决问题的其他尝试




  • 第一次从源代码提交(git)回购,rcheckin创建共享库



    我的问题



    我需要做些什么才能使TFS保持最新状态从git-repo释放分支,以便git中的每个提交都有相应的TFS变更集?

    其他信息



    我确实拥有两种回购的管理控制权,并且可以重新分配git必要时进行回购,这意味着所有后果。我只是不想丢失我们已经创建的历史记录。 解决方案

我想你看到的是git-tfs只使用HEAD和tfs / default之间的最短路径提交。 TFS的历史记录是一个变化列表,而git是一个图表,而你正在达到两者之间的阻抗不匹配。为了得到git-tfs看到的图片,在使用rcheckin之前,试着 git log --graph --oneline --decorate HEAD tfs / default



如果你想要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

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

  git tfs克隆http:// tfs:8080 $ / tfsrepo 
cd tfsrepo
git remote add github git@github.com:REPO / Repo.git
git fetch github
git checkout -b将被重写的两次github / release
git rebase tfs / default
git tfs rcheckin

查看 rebase docs 为更多事例rebase可以做。



并且不 git push github即将被重写-twice:释放


The Context

  • We have a git repository with a release branch.
  • We have a TFS repo (currently empty).

My task is to mirror the release branch of the git repo into TFS so that every commit in git maps to a changeset in TFS. All the developers only commit to git and (lets assume) are unaware of TFS.

Reading the documentation for rcheckin and the answer to this related issue makes me believe that rcheckin is capable of doing that.

The Problem

All the commits in git are squashed into a single changeset.

Reproduction sequence:

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

This results in a single checkin into TFS that contains all the commits.

Other attempts at solving the problem

  • After clone, merge the first commit from the source (git) repo, rcheckin to create a shared base

    • This worked, but subsequent git pull github release followed by git-tfs rcheckin led to commit squashing again.
  • For the first few commits in the origin repo, I merged them one-by-one into the git-tfs shared repo and rcheckin'd after each.

    • This kind of worked, as for every commit, there was one changeset in TFS. However, the original commit message second underneath a "merged c02436de4f.." message.
    • It is not realistic to do for every changeset, even with scripting.
    • As pointed out by patthoyts, this would make me the commiter for that change as far as TFS is concerned.

My question

What do I have to do to keep TFS up-to-date with the release branch from the git-repo so that every commit in git has a corresponding TFS changeset?

Additional info

I do have administrative control of both repos, and I would be able to rebase the git repo if necessary, with all the consequences this implies. I just don't want to lose the history we already created.

解决方案

I think what you're seeing is git-tfs using only commits along the shortest path between HEAD and tfs/default. TFS's history is a list of changes, while git's is a graph, and you're hitting the impedance mismatch between the two. To get a picture of what git-tfs is seeing, try git log --graph --oneline --decorate HEAD tfs/default before you use rcheckin.

If you want the 1:1::commit:changeset thing, try this:

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

Another approach is to use cherry-pick or 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

Check out the rebase docs for more examples of things rebase can do.

And don't git push github about-to-be-rewritten-twice:release.

这篇关于git的一对一映射使用git-tfs rcheckin提交给TFS变更集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆