views:

239

answers:

3

Hello. I'd like to see how TFS will work for my command. So I'd like to move our current GIT repository to TFS database. We've used GIT for it's prevailed branching support so I'd like to use TFS 2010 to address that issue.

Now question is. How do I export our GIT repo to TFS. Obviously it's some kind of script. Does have anyone done that? Any suggestions?

Thank you.

A: 

You may be able to export git to svn, and use CS Converter to go from svn to TFVS. Note - CS Converter has been discontinued, but it looks like you can still download it.

brianegge
A: 

Set up a SVNBridge to TFS and then use git-svn clone.

TwistedStem
It's git svn update but you are right. I've done exactly this thing.
Artem Tikhomirov
+1  A: 

I created a quick batch file, but you need to have Team Foundation Power Tools (tfpt.exe) in your path and For (a command line loop command)

Visual Studio Command line to your desired git folder and run the following.

git log --pretty="'%H',%ci - %s" --reverse > commits

tf workspace temp /new /s:http://{TfsInstance} /i
tf workfold /map %2 . /workspace:temp

FOR /F "tokens=1* delims=','" %%a IN (commits) DO git checkout %%a && tfpt online /recursive /exclude:.git*,commits,*.obj,*.exe,_ReSharper*,obj,debug,*.user,*.suo,Bin /adds /deletes /i && tf checkin /author:"{AuthorName}" /comment:"%%b" /i

tf workspace temp /delete /i

First it creates a commits file with all the commit information in reverse order (earliest first).

Then it creates a Team Foundation workspace... (be sure to replace {TtsInstance} with your TFS uri.

Then it creates a temporary folder in the workspace.

Thne it loops through each line in the commits file, does a checkout from git, uses TFPT to check in the current files (again be sure to replace {AuthorName} with your author name) the comment will include the timestamp from git (unfortunetly you can't change checkin time without changing the TFS server's time and I would recommend against that) and the original author's name.

This worked okay, but branches won't be perserved. I didn't take the time to figure out branching since it wasn't a big enough factor for the job at the time.

Hopefully this can save someone some time!

TwistedStem