Push git repository into TFS from scratch

949 views
Skip to first unread message

vas...@gmail.com

unread,
Dec 7, 2011, 4:11:10 AM12/7/11
to git-t...@googlegroups.com
Out team have been used Git for a few months and are happy with it. But TFS is a corporate standard and we have to mirror our Git repository into TFS (one-way - push git changesets into TFS only). 

Each and every git-tfs sample starts form git-tfs clone command which creates new git repository based on a TFS project. 
In our case we need to do the reverse thing: create a new TFS project (or branch or whatever) based on a (central) git repository. 

So the questions: Is it possible? How to do it?

Thanks.

Ivan Danilov

unread,
Dec 7, 2011, 7:38:34 AM12/7/11
to git-t...@googlegroups.com
Yes, it is possible, but it would be hard time to wait for rcheckin to transfer 3 months of work to TFS. It is not very efficient and was intended to use with several commits (or several dozens of commits). The main problem is that it performs rebase after each commit checked in to TFS because of changed commit comment (and as a consequence - changed sha).

Also git-tfs supposed to do `git tfs clone` to empty repository, but it is easy to workaround (I don't know right now why this restriction is there, honestly): just clone empty target TFS repository to new git repository (so that git-tfs bindings set) and then add your main repository as new remote and fetch from there. After that rebase your mainline to tfs/default (which is empty, so no conflicts presumably) - and you have everything you need to run `git tfs rcheckin`. I didn't tested this, but the approach should be workable.

I'd recommend (if it is acceptable to your situation of course) to make first `git tfs checkin`, so all your 3 months will go to very first TFS changeset in your repository. Thus you can avoid the problem I mentioned in first paragraph. In git you will have all your history and one merge commit in the end (so, two convergent branches: one is tfs/default which has 2 commits - initial and merge commit with all changes; second is your mainline with all your work and that merge commit also in the end). After that you can execute git tfs rcheckin to mirror your history fully.

If it is not - you can try to execute rcheckin (run it with -d option to see the process and be prepared for waiting to finishing from several hours to several days though, depending on how much commits/files you have). If it can't help you either - probably you should modify sources of rcheckin, so that it doesn't rebase and take commits one by one (it shouldn't be pushed to mainline because it is not safe in case rcheckin is not the only one who can checkin to TFS in every single moment of time).

Matt Burke

unread,
Dec 7, 2011, 8:50:10 AM12/7/11
to git-t...@googlegroups.com
I'll second Ivan's advice, especially the bit about doing your initial
push into TFS with a `git tfs checkin`. Ivan pointed out that it's
going to be much faster to do a checkin. I'll add that, because
rcheckin rebases your git branch, it's going to be fairly disruptive
to your team's workflow, especially for the first rcheckin.

Also, git-tfs can clone (or init) from inside an existing repository
(or, it used to be able to). The examples all start fresh because
that's, I think, the common case.

--
Matt

> --
> You received this message because you are subscribed to the Google Groups
> "git-tfs-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/git-tfs-dev/-/DItyDctMovoJ.
>
> To post to this group, send email to git-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> git-tfs-dev...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/git-tfs-dev?hl=en.

Ivan Danilov

unread,
Dec 7, 2011, 8:58:56 AM12/7/11
to git-t...@googlegroups.com
Well, if the team members don't have long unmerged-to-mainline branches - rebase would just require much network bandwidth to clone new version. I presume that Vasily's git repository is local so it won't be much of a problem. But nevertheless, good addition, I totally forgot about that :)

Ivan Danilov

unread,
Dec 8, 2011, 3:01:41 AM12/8/11
to git-t...@googlegroups.com
I've just uploaded https://github.com/git-tfs/git-tfs/commit/f604a202871f22cdc1210adfa0c3eff10a16491b which will hopefully solve the problem with rcheckin slowness. To run it you need to pass --quick option to rcheckin which means that rcheckin is not supposed to do rebases and just go through commits and apply them to TFS.

It also doesn't update current reference afterwards, so you should see two identical branches (one from tfs/default and another from your current position).

Note that it is new and not used before, so there could be bugs :)

ricardo...@gmail.com

unread,
Jun 8, 2017, 10:34:02 AM6/8/17
to git-tfs-dev
Hi Ivan,

I have the same question as the original Post. We have a Git repository and would like to create a new TFS repository (TFS 2013). Could you point me to instructions on how to do this? I am not a Git expert and do need step by step instructions.

Thank you.

Philippe Miossec

unread,
Jun 18, 2017, 2:29:25 PM6/18/17
to git-tfs-dev, ricardo...@gmail.com
Git-tfs is not made for this.

Git-tf could do that only for one branch but has been disconitunated by Microsoft.

I'm not sure you will be able to do it :(
Reply all
Reply to author
Forward
0 new messages