One-to-one mapping of git commits to TFS changesets using git-tfs rcheckin

a 夏天 提交于 2019-12-03 15:29:18

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.

I don't think this is going to come out well. If you do fix making the commits, each one will have the timestamp and user id of the moment you comitted to TFS. You can't preserve the original author or time when comitting these to TFS. You might be better off waiting as Microsoft have announced TFS will in future support Git. So before too long anyone needing to use tfs can upgrade their tools and access your real git repository.

I suspect your merge made a merge commit and that is causing the squash. You might try resetting the git-tfs branch to your git master and then pushing the commits. We use git-tfs the other way around where the shared repository is TFS and we all use git with git tfs to make commits. If I create a branch and add a few commits then git tfs rcheckin does not squash these into one but makes a series matching what I have in my local git. I did find that using 'stage' and then unstaging in tfs to make a commit squashed everything into one. You didn't say why you have to mirror to TFS but I suggest you try and point them at the recent microsoft announcements and tell them git is the future! Even with TFS. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!